A guide to getting started with Git and Github

Git and GitHub are your real friends, this article is just to make yourself comfortable with them

At first-look, Git can seem like a complicated, possibly intimidating tool. But if you look closer, you’ll see that it’s just a system that stores files. However, unlike a regular file server which only saves the most recent version of a file, Git keeps track of all the different versions that we create as we save our changes.

On the other hand, GitHub is a web-based Git repository hosting service. On top of the version control functionality of Git. GitHub lets us share and access repositories on the web and copy or clone them to our local computer, so we can work on them.

Enough introduction, lets download Git from https://git-scm.com and sets it up for the first time if you don’t already have it on your system.

If you are a Linux or Mac user, can follow these instructions

Once you have installed, let’s try the following steps…

Create a Github account and then create a repository by following the demonstration below. If you want to include the README file, Click “Initialize this repository with a README”. It’s super easy, just make yourself comfortable a bit

Open a Command Prompt or the GIT Bash terminal preferably and run the commands to configure your Git username and email by replacing “my_username” and “my_email@example.com” with your own.

git config --global user.name "my_username"
git config --global user.email "my_email@example.com"

These details will be associated with any commits that you create and now you are ready to use git on your computer!

On GitHub, navigate to the main page of the repository. Under the repository name, click Code and simply open the Git bash window on windows or the Terminal windows for mac and Linux. Then type the following command and press Enter

git clone "paste the URL you just copied"

You can also Clone your repository by the following example if you face any difficulty above

Now, get into the repository and you possibly have some files to put into your repository, or maybe you want to edit some file. You can do whatever you want. Let’s add a “hello.py” file to our GitHub repository, some code and check the status by running

git status

You will see an untracked “hello.py” file, with a red mark. Because the file is not added to the repository and git isn’t tracking this file. So, let’s add the file with the command below

git add <filename_one>

Great! You just have added a file to git. From then git started tracking your file. If you have lots of files changed and you want to add them all, use

git add --all

A git commit can reference bugs or issues that will be fixed with the change. It can also include links to more information when relevant. It’s frustrating to go back to repositories history and discover that there’s not enough context to understand what was changed and why. It takes only a few more seconds to write a better description.

Till now you created a repository, downloaded it locally, made changes, and added those changes to git. Now You can commit these changes with the command

git commit -m "<add your commit message here>"

You did a great job! Now if you are happy with your changes and want to push your files to Github, simply run the command

git push


git push origin master

Congratulations! 🎉 🎉 🎉

You made it 😊

You may be interested to read more. Best wishes for the next step

Full-Stack Web Developer