What is Git ?

Git is the free open source distibuted version control system. Git keeps track of changes to the content ie, source code files, and provides you mechanism for sharing that content with others.
Git helps you contributing in some of the most famous open source projects like facebook-react, phpMyAdmin, Microsoft-vscode, Mozilla and so on. You can make contibutions by poviding solutions to some of the known bugs or by providing new bugs or suggestions for the improvements.

Documentation: https://git-scm.com/

How to install git in linux?

sudo apt-get install git

Git basic configurations:

Your Name: git config --global user.name "John Doe"
Your Email: git config --global user.email johndoe@example.com
Checking you Global Settings: git config --list
Checking git version git --version
Git help man git

Github:

Github is a hosting service which provides you repositories for version control. So github is basically an online storage of you git repositories.

Git Repository:

A repository (usually abbreviated to “repo”) is a location where all the files for a particular project are stored. Each project has its own repo, and you can access it with a unique URL.

Forking a Repo:

“Forking” is when you create a new project based off of another project that already exists. This is an amazing feature that vastly encourages the further development of programs and other projects. If you find a project on GitHub that you’d like to contribute to, you can fork the repo, make the changes you’d like, and release the revised project as a new repo. If the original repository that you forked to create your new project gets updated, you can easily add those updates to your current fork.

Pull requests:

You’ve forked a repository, made a great revision to the project, and want it to be recognized by the original developers—maybe even included in the official project/repository. You can do so by creating a pull request. The authors of the original repository can see your work, and then choose whether or not to accept it into the official project. Whenever you issue a pull request, GitHub provides a perfect medium for you and the main project’s maintainer to communicate.

Adding public key to github

Generating SSH Key: ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
When you’re prompted to “Enter a file in which to save the key,” press Enter. This accepts the default file location.
Enter the passphrase to be used to unlock the public key when used for the first time.
Adding ssh key to ssh agent:

$ eval "$(ssh-agent -s)"
$ ssh-add ~/.ssh/id_rsa

Getting ssh key: cat ~/.ssh/id_rsa.pub
After running above script copy your ssh key. Now login to your github account. Go to Settings->SSH and GPG keys->New SSH Key. Add desired title for the ssh key and then paste the copied ssh key to the 2nd input box and click on Add SSH Key.
After successfull addition of the ssh key, you key will be shown up in the SSH and GPG Keys section.

Some useful git commands:

Command Usage
git init Initialising a git repository in the woking directory.
git remote add origin Adding origin for the repository on github.
git remote -v To know about the remote origins of the repo.
git remote remove origin To remove oigin of the github repo from current git enabled directoy.
git add -A or git add . To add all the unstaged or untracked files.
git add <filename> To add a particular file to stage or to track.
git commit -m "<message>" To make a commit for the changes you have made with a message.
git commit -S -m "<message>" To make a GPG key signed commit for the changes you have made.
git push origin <branch_name> To push the changes to the branch in the repo on which you are working.
git status Gives the status of the repository and untracked or unstaged files.
git branch Gives the list of all the branches.
git checkout -b <branch_name> Create a new branch in the repository.
git checkout <branch_name> Swith to the branch with banch name branch_name.