Essential Git Commands Last Updated : 22 Nov, 2021 Comments Improve Suggest changes Like Article Like Report When it comes to commands, there come numerous commands in a software developer head or one that is mastering over git but even only a few of them are used frequently in the enterprising domains that are used frequently by developers in order to boost workflow. So here we will be listing a couple of them prior to dividing them into categories in order to perceive real quick. These commands are peculiar curated allowing to go from scratch from creating a new repository and playing further creating branches, merging to master branch. Categories are as follows: To createTo make local changesTo commit historyBranches and tagsTo update and publishTo merge and reuseTo undo Let us do define commands that do fall under these categories that are listed below as follows: Type 1: CREATE Clone an existing repository: git cloneCreate a new local repository: git init Type 2: LOCAL CHANGES Changed files in your working directory: git statusChanges to tracked files: git diffAdd all current changes to the next commit: git addAdd some changes to the next commit: git add -pCommit all local changes In tracked files: git commit -aCommit previously staged changes: git commitChange the last commit: git commit --amend Type 3: COMMIT HISTORY Show all commits. starting with newest: git logShow changes over time for a specific file: git log -pWho changed what and when in: git blame Type 4: BRANCHES & TAGS List all existing branches: git branch -avSwitch HEAD branch: git checkoutCreate a new branch based on your current HEAD: git branchCreate a new tracking branch based on a remote branch: git checkout - -trackDelete a local branch: git branch -dMark the current commit with a tag: git tag Type 5: UPDATE and PUBLISH List all currently configured remotes: git remote -vShow Information about a remote: git remote showAdd new remote repository, named remote: git remote addDownload all changes from but don't integrate into HEAD: git fetchDownload changes and directly merge/integrate into HEAD: git pullPublish local changes on a remote: git pushDelete a branch on the remote: git branch -drPublish your tags: git push --tags Type 6: MERGE & REUSE Merge into your current HEAD: git mergeRebase your current HEAD onto git rebaseAbort a rebase: git rebase - -abortContinue a rebase after resolving conflicts: git rebase - -continueUse your configured merge tool to solve conflicts: git mergetoolUse your editor to manually solve conflicts and (after resolving) mark tile as resolved: git add, git rm Type 7: UNDO Discard all local changes in your working directory: git reset -hard HEADDiscard local changes in a specific file: git checkout HEADRevert a commit (by producing a new commit with contrary changes): git revertReset your HEAD pointer to a previous commit and discard all changes since then: git reset --hardPreserve all changes as unstaged changes: git resetPreserve uncommitted local changes: git reset - - keep Comment More info J jhakrraman Follow Improve Article Tags : Git GitHub Explore Git Tutorial 6 min read Git IntroductionGit Introduction 11 min read Introduction to Github 5 min read An Ultimate Guide to Git and Github 12 min read What is Git? 6 min read What Is Gitlab? Complete Guide 4 min read Git Bash 9 min read Git Installation and SetupHow to Install GIT on Linux 4 min read How to Install Git on Windows Command Line? 3 min read Git - Environment Setup 2 min read How To Install Git on Ubuntu 20.04 3 min read How to Install Git in VS Code? 2 min read How to Install Git on Cygwin? 2 min read How to Install and Use GIT in Android Studio? 4 min read How to Setup Git Using Git Config? 3 min read Git- Setting up a Repository 3 min read How to install Git on Redhat Linux 9? 4 min read How to Install Git on Termux? 2 min read How to Install Git in FreeNAS? 4 min read How to Install Git on Raspberry Pi? 2 min read How to Install GIT on VMWare? 2 min read How to Install Git in Cpanel Server? 3 min read How To Install Git on AWS? 2 min read How to Setup Git Server on Ubuntu? 6 min read How to Install Git on Windows Subsystem for Linux? 2 min read All Git CommandsBasic Git Commands with Examples 4 min read 50+ Essential Git Commands for Beginners and Developers 7 min read Top 12 Git Commands for Every Developer 9 min read Essential Git Commands 3 min read Useful Git Commands and Basic Concepts 5 min read All Git Commands You Should Know 8 min read Simple and Concise Git Commands That Every Software Developer Should know 4 min read Most Used Git CommandsWhat is Git Init? 6 min read What is Git Pull? 6 min read What is Git Push? 8 min read What is Git Clone? 7 min read Git Rebase 8 min read How To Fetch Remote Branches in Git ? 3 min read Git - Status 3 min read What is Git Add? 3 min read What is Git Commit? 5 min read Git Reset 3 min read Git BranchBranching Strategies in Git 8 min read Introduction to Git Branch 4 min read How To Create Branch In Git? 2 min read How to Create a Branch In Git from Another Branch? 3 min read How to Create a New Branch in Git and Push the Code? 8 min read How To Publish A New Branch In Git? 4 min read How to Create Git Branch With Current Changes? 1 min read Create a Git Branch From Another Branch 4 min read How to Create a New Branch in Git? 4 min read How to Create Branch From a Previous Commit Using Git? 2 min read How To Visualizing Branch Topology in Git? 3 min read How to Check Branch in Git? 2 min read How to Clone a Branch in Git? 3 min read How to Fetch All Git Branches? 2 min read Git MergeGit - Merge 5 min read Git Checkout And Merge 6 min read How to Merge Two Branches in Git? 4 min read How to Merge a Git Branch into Master? 3 min read How to Replace Master Branch with Another Branch in GIT? 2 min read Git Merge and Merge Conflict 3 min read Git Tools and IntegrationWorking on Git for GUI 4 min read How Git Version Control Works? 11 min read How To Write CI/CD Pipeline Using GitLab? 8 min read Git and DevOps: Integrating Version Control with CI/CD Pipelines 11 min read How To Create A Basic CI Workflow Using GitHub Actions? 5 min read How To Set Up Continuous Integration With Git and Jenkins? 4 min read How to Set Up a CI Pipeline for Ktor Using GitHub Actions? 6 min read Introduction to GitHub Actions 4 min read Basic CI Workflow For Android using GitHub Actions 2 min read Integrating Jenkins With Popular GitHub 8 min read Managing Git Repositories with GitLab 3 min read Git Remote RepositoriesUnderstanding Version Control with Git 8 min read Git- Setting up a Repository 3 min read Creating Repository in GitHub 3 min read Working With Git Repositories 7 min read Collaborating with GitGit - Fork 5 min read Difference Between fork and clone in GitHub 3 min read How to Fork a GitHub Repository? 3 min read Sync Your Fork With Master in GitHub 3 min read How to Update or Sync a Forked Repository on GitHub? 2 min read Like