GitHub basics

Nwosu Ifeoma
3 min readMay 7, 2018

--

From Google, GitHub is a web-based hosting service for version control using git. It is mostly used for computer code. It offers all of the distributed version control and source code management functionality of Git as well as adding its own features.” Version control is basically a system used to track changes being made to files so that you can easily reference the older versions.

This technology is a rather important tool for any programmer to master. It may seem quite confusing at first, I know it was for me, but continuous usage helps one to master it. Below I’ll take you through the steps of pushing a file to Github.

First of all you must surely have a GitHub account and also have a version of Git downloaded on your PC.

Next, you have to create a new repository from your GitHub account, you can do this either by clicking on the “New Repository” button (a green button to the left) or by clicking on the + button.

Now we go to our file, right click and click on “Git Bash here…”. In the command line interface we type in git clone <url>. For example,

git clone https://github.com/IfeomaLucia/Anagram.git

This command clones(downloads) your repo to the working directory so you can do your work on it before pushing it back to GitHub.

cd Anagram

The above is to enter into the directory of your file. You’ll also have to ensure that the file to be uploaded is inside your directory(i.e the folder) before any futher processes is done on the Git Bash.

Next, we check the status of our repo by typing in git status, thislists out the basic info of our file and shows the user that there is an untracked file(if there’s any). This can now be added by using anyone of the syntax shown below

git add -A //this adds all untracked files
or
git add <files> // you use this when you want to specify a particular file

Next, we include a commit message which basically tells any user of the changes you’ve made to the file at any point in time. The syntax is as shown below…the flag -m is a shortcut for writing messages.

git commit -m 'include your commit message here'

In case of any changes to your file, you also have to push this new section of the file. This is done by using the git add syntax shown above. You also have to include another commit message if you add any new file. To track the changes being made between any two commit messages, you’ll use

git diff <firstLogNumber> <SecondLogNumber>

The log numbers of commits can be gotten when we type git log, this displays all the commit messages and their respective log numbers.

Finally, when you are done making any reasonable changes to your program(or file), you can now take the final step to push your file to GitHub. This is done by typing,

git push origin master

--

--