Top 20 Git commands

Top 20 Git commands

Git is a distributed version control system (DVCS) widely used for tracking changes in source code during software development. It was created by Linus Torvalds in 2005 to manage the development of the Linux kernel, and since then, it has become one of the most popular version control systems in the world.

Most Used Git commands

git --version # Checks whether your System has Git or not
git init #initializes a new repository
git add <file> #Add file to the staging area
git commit -m "message" #Commit changes with a message
git status #check status of working directory
git log #View commit history
git branch #shows us all the branches
git checkout -b <branch> #Create and switch to the new branch
git merge <branch> #merge changes from another branch
git remote add origin <url> #add a remote repository
git push -u origin <branch> #push changes to remote repository
 git pull origin <branch> #pull changes from the remote repository
git clone <url> #clone a repository from the remote
git config --global user.name "Your name"
git config --global user.email "your.email@example.com"
 git log --author=<author> # show commits logs by a specific author
 git log --grep=<pattern> #show commit logs with messages match a pattern
git revert <commit> #revert a commit
git fsck #checks the integrity of the git repository
git rm <file> #removes a file from the staging area

Did you find this article valuable?

Support Thirumalai by becoming a sponsor. Any amount is appreciated!