Aaron Bachman
5 min readDec 5, 2022

A step by step guide: using git and GitHub as source control on a centos 7 server.

What is git and GitHub? Git is source control software that allows people and companies to keep track of changes to software. GitHub is a internet hosting service for software development and version control using git.

As I continue on my journey into DevOps and cloud engineering git and GitHub will be important tools that will allow me to collaborate with others.

Here are some basic requirements:

  1. First you will need a basic knowledge of linux and its commands, vim text editor and a centos 7 server.
  2. A GitHub account.
  3. A Centos 7 Linux server.
  4. Access to a computer.

Getting started:

The very first thing we will do after your GitHub account has been created is called forking… Yeah I thought huh? Glorkian warrior kids books getting to me, but in this case forking is used to create an exact copy a repository, (repo for short) on GitHub. This will allow us to work on our own copy without making changes to the master repo.

To fork the repo click on the fork button as seen in the picture. (Upper right corner).

After you have added a description click create fork. After creating your fork you have also created your first repository, and this is where you will be making changes.

Next up we will need to install git on your Centos7 server.

Step 1. ssh into your server, in my case I am using A cloud guru server.

Step 2. Install git on your server.

If you see this you are good to go, if not it will ask you if it is ok to install; type y and enter.

Step 3. Configuring git

Step 4. Let us make a directory for our soon to be cloned forked repo titled Project 2.

Step 5. Cloning

Now let’s clone our forked repo, and just what is cloning? Cloning makes an exact copy of the repo we forked early that is available for us to work on locally (our server). In this case we will be using HTTPS in the code button to clone our repo.

Click the green Code button, make sure HTTPS is selected and copy the link provided.

Let’s use cd to change to the proper directory and list the files with ls.

All of our ropo files are here!

Step 6. Making changes to our ropo files

Next we are going to open a text editor; in my case vim to edit our file.

Once in vim I will make a small change in the linux.sh file by adding my name.

:wq will save and quit vim and quit vim.

Now lets run a git status command and we will see:

We have a file that has been modified: linux.sh

Step 7. Add

Next we will tell git to watch for this particular file and changes made to it.

Now run another git status check to see what it looks like.

Step 8. Commit changes

Be descriptive with your commits, it is important that other people know what was done

Now if we run the git status command again we will see:

Our directory is clean and ready to go

Step 9. Push

Next we are using another strange term, that is an apt description. We will push our new commit to our forked repo (origin).

You will next be prompted for your GitHub credentials, (username and password). However GitHub no longer accepts passwords to allow a push go through. You will need to go to the GitHub website and generate a personal access token. Here are the steps needed to complete this process.

  1. Click your profile photo and then click settings
  2. Click developer settings in the left sidebar.
  3. Click Generate a new token
  4. Give your token a name
  5. Select the permissions for your key (I selected all for this one)
  6. Keep this token safe as you would passwords and other keys

Whew finally we are almost done. Now lets go to the original repo on GitHub and look to see if the changes made it through. Click the linux.sh file

When we click on the file we can see the changes made to it.

Step 10. Creating a pull request

Now that we have our changes back to our original repo we can now make a pull request to view the changes that you have made. The owner or owners will decide if they want to incorporate your changes. Click the pull requests tab, and then click the New pull request button.

Add a description of the changes made.

Congratulations!! You have now contributed to a file on GitHub. You will be well served by your new skills in the future! Forking, cloning and pushing, now, not such strange terms. I hope you enjoyed this short tutorial and I will see you again in the future.

Aaron Bachman

Level Up in Tech student. DevOps, Cloud engineering, AWS, Terraform.