List Of Various Git Commands


Today we will be discussing the various Git commands and their usage. Firstly let’s look at the most important question “What is Git”. Git is a version control system and the most well-known way of managing the version of the code files. Every day we make changes to the code files and in order to track these changes correctly we maintain versions of the files. Git can be used to easily manage these version of the files . Below are the some of the important commands from Git which can be used to manage the versions and various other operations in Git.

Git Commands

For the first time when you're  connecting to git, register your name and email so that every change is commented with your name and email.
git config --global "Virender Verma"(
git config --global ""
The below command is for listing down all the commits that have happened so far for the project you are currently working on.
git log
Start working on a new project directly from GIT by following the below steps,
  1. cd D:\Projects --> Browse to the place where the project is to be created (Could be D Drive or some place in C Drive). For my example it is D drive and “projects” folder.
  2. git init HelloWorld --> This command will create a folder for the project named "HelloWorld" and initialize it with GIT
  3. cd HelloWorld --> To get into the newly created project folder and start working
If the project is already present locally but not yet initialized then use the below commands,
  1. cd D:\Projects\GetItemsFromSPList --> browse to location of the project folder. In my case it is "GetItemsFromSPList" folder in D drive.
  2. git init --> Initialize GIT with the project folder. In my case it is "GetItemsFromSPList"
After making the changes to the project files, use the below commands to commit your changes,
  1. cd D:\Projects\GetItemsFromSPList --> Browse to location of the project folder. In my case it is "GetItemsFromSPList"
  2. git status --> Which files are modified and not yet synched with GIT
  3. git add Abcd.txt --> Tells Git to start tracking specific files under the project folder. In this example it is “Abcd.txt” file
  4. git add . --> “.” Tells Git to start tracking all files and folders under the project folder
  5. git commit -m "A really good commit message" --> commits the changes to GIT with the message
In case any file is to be reverted to previous version and changes in that file are to be discarded, then we can see the below commands,
  1. git reset HEAD abcd.txt --> remove the tracking of the specific file in case that file is never to be committed. In my example: it is abcd.txt
  2. git checkout -- abcd.txt --> reverts the file to its previous version.
In case some file is deleted from the project folder and now you want to delete them from Git as well then use the below commands,
  1. git add -u --> to start tracking the files which are deleted
  2. git commit -m "Deleted files synched with GIT" --> commits the changes to GIT
That is it. I hope you have learned something new from this article and will utilize this in your work