Setting up Git Repository for Ansible

Install DNF on the Client Side

$ dnf install git
 Package             Architecture  Version               Repository        Size
 git                 x86_64        2.31.1-3.el8_7        appstream        160 k
 git-core            x86_64        2.31.1-3.el8_7        appstream        4.8 M
 git-core-doc        noarch        2.31.1-3.el8_7        appstream        2.6 M
 perl-Git            noarch        2.31.1-3.el8_7        appstream         77 k

Transaction Summary
Upgrade  4 Packages

Total download size: 7.6 M
Is this ok [y/N]: 


Do sign up for an account if you have not done so. At, create a new Repository and give it a new name. Look at the pix for more information

Once you have created the repository, you should have something like this

At the profile Icon, click settings, you should enter the page where “SSH and GPG Keys” are present

Click the new SSH icon

Type the name of the key (Your Choice) and copy your ssh public keys into the key box. This can be found at ~/.ssh/ or ~/.ssh/ Copy the whole string and paste into the key box

Git Clone the Repository URL

Go back to your repository and copy the code


At the Linux Server….

git clone the URL

$ git clone             
Cloning into 'ansible_cluster'...
Warning: Permanently added ',' (ECDSA) to the list of known hosts.
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.

At your directory go to the ansible_cluster folder, you should be able to see the file which is same as your git repository.

$ cd ansible_cluster
$ cat
# ansible_cluster

Setting some basic git information like user name and email address

$ git config --global "user1"
$ git config --global ""
$ cat ~/.gitconfig
        name = melvin soh
        email =
        defaultBranch = main

Pushing and cloning to the git repository

Let’s make some changes to the

$ vim


Checking their Status

$ git status
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)

no changes added to commit (use "git add" and/or "git commit -a")

Add the changes, coming and pushing the changes to git

$ git add
$ 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)

$ git commit -m "Updated Readme file on 8/5/2023"
[main 06583ec] Updated Readme file on 8/5/2023
 1 file changed, 3 insertions(+), 1 deletion(-)

$ git push origin main
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Writing objects: 100% (3/3), 308 bytes | 102.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
   5524665..62b9b0a  main -> main


  1. Top 20 Git Commands With Examples
  2. Learn Linux TV Chapter 3

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.