top of page

Basic version control using Git Hub

Updated: Aug 1, 2023

To check whether git CLI is available locally, type

which git

/usr/bin/git

If not installed,

sudo apt install git

On git-hub page create a ansible-tutorial page

Add your public key to github account by

login to https://github.com/ with your a/c

goto profile - settings - ssh and GPG keys

Add new SSH Key

Give title

login to your Ansibble controller laptop and copy the public ssh key

and paste it into github page

In the terminal type the following:

ls ~/.ssh

cat

copy paste the ssh from terminal and paste it on the Github ssh addition box

Clone the github repository you created "ansible-tutorial" page

Important

while copying URL from github, choose the ssh URL. Without knowing I took, https, it didn't work


git clone git@github.com:snsmssss/ansible-tutorial.git

Cloning into 'ansible-tutorial'...

Enter passphrase for key '/home/sambath/.ssh/id_ed25519':

remote: Enumerating objects: 3, done.

remote: Counting objects: 100% (3/3), done.

remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0

Receiving objects: 100% (3/3), done.


git config --global user.name "Sambath Parthasarathy"

git config --global user.email "sambath.narayanan@gmail.com"

To check, cat ~/.gitconfig

[user]

name = Sambath Parthasarathy

email = sambath.narayanan@gmail.com


if you don't confiig git willl complain

edit README.md in /shared/TRANZ1/ANSIBLE/ansible-tutorial


git add README.md


git add .

(instead of file name you can put .(dot), which will update the entire folder). When you type status, you get

git status

On branch main

Your branch is up to date with 'origin/main'.


Changes to be committed:

(use "git restore --staged <file>..." to unstage)

modified: README.md


git commit -m "updated Readme.md file"

git commit cmd, m for message with what did I change. Output says updated as follows:

[main 01268b4] updated README file

1 file changed, 5 insertions(+)

At this stage if you go to github oage you won't see the update

one more step, to send the chnages to the github server, as given below

git push origin main

(old command contains master, new command contains main), out looks as follows:

Enter passphrase for key '/home/sambath/.ssh/id_ed25519':

Enumerating objects: 5, done.

Counting objects: 100% (5/5), done.

Delta compression using up to 16 threads

Compressing objects: 100% (2/2), done.

Writing objects: 100% (3/3), 298 bytes | 298.00 KiB/s, done.

Total 3 (delta 0), reused 0 (delta 0)

To github.com:snsmssss/ansible-tutorial.git

c7528a7..01268b4 main -> main

Go back to repository and check whether modifications are updated.

You can develop code locally and keep updating the repository.


bottom of page