Setup of Git & GitHub


What is Git

Git is an open source distributed version control system which can be installed on users’ machines and its command line interface helps to perform different activities on Repositories.

What is GitHub

GitHub is a Web-based repository hosting service which is built around the Git tool and it offers all of the distributed revision control and source code management functionality of Git as well as adding its own features.

Git Installation

Git can be installed with any of the options provided in the link.

Git User Configuration

After installing Git , Username and email configuration needs to be set using git config commands.This information is used by the activities performed on Git like committing changes. If this configuration is set with “–global” option, user need not set this every time on the system but if this has to be temporary, it can be set without “–global” option.

command: git config –global “<user name>”

command: git config –global “<user email>”

Configuration can be verified with the git config –list command.

command : git config –list

Git Work Flow

There would be 2 types of repositories in Git workflow. One would be in GitHub which is “Central/Remote Repository” and other is in users machines which is “Local Repository”.

Local Repository

There are two more stages involved in local git before the code is in local repository, those are working directory and Staging area. Before code reaches to Central Repository which is in GitHub it should cross these stages which can achieved by using some git commands available to add, commit and push the code.

Central/Remote Repository

Central or remote repository can be configured in GitHub dashboard. It would be connected with local setup to host the content.

GitHub Signup

GitHub Link :

Click on the above link and signup to work on GitHub.

GitHub Work Flow

In GitHub dashboard there would be an Organization which hosts the Repositories and Branches under Repositories. Different types of branches can be created in repositories as per project requirements.

Upload SSH Keys in GitHub

In order to upload SSH keys in GitHub, first keys need to be generated in local machine using ssh keygen command . As a result of this, a Private-Public Key-pair gets generated. Private key is stored in local machine and Public key has to be uploaded to GitHub. While doing this, the required directory and passphrase can be entered or if clicked “Enter”, default details would be configured which would be the default .ssh folder (usually under /Users/<user>/.ssh and there would be no passphrase.

command : ssh-keygen

Both keys would be generated in the given path with the below format. Here “id_rsa” is the private key and “” is the public key.

Open the file and copy the key to upload in GitHub.

Next login to GitHub and go to the account section on top right corner. From the dropdown list select “Settings”.

Under Settings, select “SSH and GPS keys”. Next click on the “New SSH key” .

Paste the copied Public key in the “Key” section and give title name. Then, click on “Add SSH key”.

SSH Public key is finally uploaded to GitHub account and it would be helpful to clone the repositories with SSH options.

Create an Organization In GitHub

After logging in to GitHub, home page would be displayed and some options would be available on right top corner, click on “+ symbol”. Select “New Organization” from the dropdown.

Some options would be shown to choose a plan. In Organizations/Companies, Enterprise option would be a good fit. But here chosen plan is Free.

Details needs to be updated along with the Organization name. Here Organization name is ” Blog-DD”

Organization would appear on the dashboard.

Create Repository In GitHub

After logging in to GitHub, home page would be displayed and some options would be available on right top corner, click on “+ symbol”. Select “New repository” from the dropdown. Also old repositories if any can be imported with “Import repository” option.

Details need to be updated along with the Repository name. Here Repository name is ” DevOpsDiggers”. Select the appropriate option from Public or Private. And, “Owner” section represents Organization name. If the option “Initialize this repository with a README” is selected, the initial commit gets pushed to the Master branch in repository.

If “Initialize this repository with a README” is not selected, some steps as shown in the picture below have to be done manually using git command line where we add, commit and push the code to Master branch.

Repository would then appear on the dashboard under Organization.

Create Branches in GitHub

Branches can be created on GitHub dashboard by using the Branch drop down. Here created new branch is Develop from Master.

Branch would then appear in repository under Branch section.


Latest Articles