Deep diving into Git and GitHub

Deep diving into Git and GitHub

Installing GIT on your system

 Git can be downloaded from here Select Windows or Ubuntu depending on the OS your system is on. Setting up git on Ubuntu is very easy. Just follow the instructions on GIT’s official website. 

1. Setting up GIT on Windows

  • Download the latest Git for Windows installer.

  • When you’ve successfully started the installer, you should see the Git setup screen.Follow the Next and Finish prompts to complete the installation. The default options are recommended for most users.

  • Open a Command Prompt or the GIT Bash terminal preferably.

  • Run the following commands to configure your Git username and email using the following commands, replacing my username with your own. These details will be associated with any commits that you create.

git config --global "your_username"
git config --global "your_email_id"

GIT is now up and running on your system.

2. Setting up GIT on Linux (Debian/Ubuntu)

  • Using the shell terminal, install Git using apt-get:
$ sudo apt-get update
$ sudo apt-get install git
  • Verify if GIT is installed in your system by typing the following command.
$ git --version
git version 2.21.0
  • Configure your Git username and email using the following commands, replacing my username with your own as mentioned earlier. These details will be associated with any commits that you create.

git config --global "your_username"
git config --global "your_emailid"

Getting your hands dirty

Now as we are done with the setup of GIT. The first question coming up in your mind would be “What is a repository?”

A repository is the collection of files and folders that are being tracked by git. The repository consists of the entire history of your team’s changes to the project. It’s the big box you and your team throw your code into.

  • Creating a repository on git.

Once you have created an account on GitHub, navigate to the repository section. Click on new. Add a relevant name for your repository.

Give the repository a valid description. Intializing your repository with a readme file and thank me later. :P

  • Adding files to your repository

    Files in a repository can be added in two ways:

    1. Via upload files option available in GitHub

    This is a very easy way in which you can add files to your repository. Just click on the upload files option and you can select the files your system which you want to upload.However, this method of uplaoding files to a repo isn’t considered as a good practice in the proffesional world.

    Note : This works fine for a repo that you have created using own account.For uploading files to a repo created by soemone else, you need to have push access to that repo.

    2. Via the GIT Bash terminal

    This is the preferred way of uploading files to a git repo. This procedure assumes you’ve already:

    • Created a repository on GitHub, or have an existing forked repository owned by someone else you’d like to contribute to
    • For cloning a repository into your system
      • Open GIT bash in the location of your choice where you want to fork the repository.
      • Type the following commands.
        git clone "link_of_the_repo_to_be cloned"

    • After cloning the repository locally on your computer

      • On your computer, move the file you’d like to upload to GitHub into the local directory that was created when you cloned the repository.
      • Type the following commands to upload the files to your repository
      • Open Git Bash.
      • Type git status
      • Since a new file has been added, it shows in red that a new file has been added. However that file isn’t tracked or staged by git.
      • Typing the following commands to stage your file and make it ready to be uploaded to your repo

       # Staging the files
       git add --all 
       # Commits the tracked changes and prepares them to be pushed to a remote repository. 
       git commit -m"An appropriate message for your commit"
       # Push the changes in your local repository to GitHub. 
       git push origin master 

    By now you must have got an idea of how a vcs like GIT works and how you can use it to make your life better.

    Contributing to open source projects on GitHub

Before contributing to projects/repositories on GitHub, one needs to know about pull requests and other such things.

So yeah, What are pull requests?

A pull request is related to version control systems. You may have several sets of users/contributors:

  • Administrators/Owners
  • Contributors
  • Testers

You want each of these people to be able to do different things:

Administrators/Owners- These people can be trusted. They might have full access to the repository in question, including full rights to commit what they want when they want.

Contributors- These might be random people from the Internet; they might be lesser people in a company. Either way, you probably don’t want them to be able to commit straight to the codebase/project - you want to review their changes first.

This is where pull requests come in. Instead of allowing straight changes to the codebase from your contributors, they will instead fork the repository, creating a copy on their local machine, and develop that. When they’re done, they can create a pull request containing their updated code. Someone in the higher group can then review their changes for correctness and complicity with standards, and merge their changes if they comply.

So yeah, that’s it. Since I have written both the blogs on GIT in a very beginner friendly way,I will keep it till here and won’t go much into the details of pull requests, branches in git,merge conflicts etc.

The next blog will be the last one of my blog series on GIT. I will be covering all the advanced concepts of branching, merge conflicts etc in it. I’ve tried to explain things in the simplest way possible. However, if you need any help with any of the topics mentioned above, feel free to reach out and ask for help.

If you liked the post,then please share it. :D

Please do let me know your thoughts, questions or suggestions in the comment section below. You can also send your feedback at

Sharjil Ahmed
Sharjil Ahmed Web Developer | Blogger | Chelsea Fanatic
comments powered by Disqus