Git: A Complete Guide. Covering the essential commands for a... | by Rahul Pathak | Towards Data Science

In a project where there are multiple collaborators, there can be conflict while building a project. Git & GitHub have provided us with the ultimate solution to such problems. Git simplifies the process of working with other people and makes it easy to collaborate on projects. In this post, we will be covering all the major commands needed to cover the workflow environment.
Here, we will be covering all the basic commands used in a workflow
Creating Repositories
Syncing Repositories
Making Changes
Parallel Development
Initially, we start by creating a repository
git init
The next step is to pull the files form the central or remote repository to your local machine.
git add origin master "link from your github account"git pull origin master
The next step is to add the files created or code developed to the index. This is known as Staging. The files are added to the index.
The index is a staging area where the new commit is prepared.
Also we can check the status. The git status command displays the state of the working directory and the staging area.
git add "file name"git add -A // to add all files in the foldergit status 
As the files are added to the index the heart of Git (Commit) comes in to place.
The “commit” command is used to save your changes to the local repository. We need to call it explicitly to see the changes.
git commit -m "your message"git commit -a -m "your message" // to commit all the files
As of now we have created a repository, synced repositories & made changes in the local repository.Now the next step is to perform parallel development.
To check the log of all commits use the command git log
git log
The parallel development consists of: -
Branching
Merging
Rebasing
Let us move ahead and perform Branching
In Git, branches are a part of your everyday development process. Git branches are effectively a pointer to a snapshot of your changes.
git branch branchname
Here it creates a branch called “firstbranch”. In this branch all the files from master branch get copied and the changes can be made available in the created branch without affecting the master branch.
To access the branch we use the command
git checkout branchname ls // lists the file in the branchcat filename //view the contents of file
Once the new branch is made it is important to merge the branch with the master branch for generating production quality code.
The git merge command lets you take the independent lines of development created by git branch and integrate them into a single branch.
git merge firstbranch
There is another way to merge the branches to the master branch. It’s called Rebase. This is more efficient as it’s used to make a linear sequence of commits. It is used for cleaner project history & reduce the number of branches.
git rebase branchname
Please make sure to create files add them & commit them in order for the change to take place and keep your code error free & running.
To Push the code from local repository to remote repository we need to authenticate first. To do that we need SSH key . GitHub uses SHA-1 Algorithm for secure hash which generate a 40 digit hexadecimal code.
ssh-keygen
To generate the ssh key type in the command
cat 'path' // usually id_rsa.pub where the public key is saved
To check whether you have successfully authenticated type in the command
ssh -T git@github.com
A message pops up saying you have successfully authenticated yourself. Once ssh key generated your good to go to push the code from local repository to remote repository. To push the files from local to remote type in the command
git push origin branchname // to push any respective branchgit push origin master // to push master branch 
Check your GitHub repositories to see the changes made from your Git
This covers the basic commands of Git.
I hope you all like this post and have understood the basic commands of Git and the workflow environment of Git. Thank you very much :)