Whether you’re working on your first coding project or managing a large software team, Git is the version control system that keeps everything organized. It tracks changes, enables collaboration, and gives you full control over your code history.
But with so many Git commands out there, it’s easy to get overwhelmed. That’s why we’ve compiled a list of the most essential Git commands you’ll actually use on a daily basis — clearly explained and ready to copy-paste.
Let’s dive in. 👇
🛠️ 1. Initialize a New Repository
Use this when you want to turn a folder into a Git repository.
git init
📥 2. Clone an Existing Repository
Grab code from a remote Git repository (like GitHub) and bring it to your local machine.
git clone <repository-url>
📌 3. Check the Status of Your Repo
See which files are staged, unstaged, or untracked.
git status
➕ 4. Add Files to the Staging Area
Select specific files or all files to prepare them for a commit.
git add <filename>
# OR to stage everything:
git add .
💾 5. Commit Your Changes
Save your changes to the Git history with a message explaining what changed.
git commit -m "message of commit "
🕓 6. View Commit History
Review a timeline of your commits.
git log
🌿 7. Create a New Branch
Start a new feature or bugfix branch.
git checkout -b <branch-name>
🔄 8. Switch Between Branches
git checkout <branch-name>
🔗 9. Merge a Branch
Bring changes from one branch into your current branch.
git merge <branch-name>
🧹 10. Delete a Branch
Clean up after a feature has been merged.
git branch -d <branch-name>
🔄 11. Pull Latest Changes from Remote
Get the most up-to-date version of the repository.
git pull
🚀 12. Push Your Changes to Remote
Upload your local commits to the remote repo.
git push
🧾 13. See the Differences in Files
View changes you’ve made since the last commit or between branches.
git diff
📥 14. Stash Temporary Changes
Save your local changes without committing them.
git stash
📤 15. Apply Stashed Changes
Reapply your last stashed work.
git stash apply
🧼 16. Rebase a Branch
Move your branch to be based on another branch’s latest commit.
git rebase <branch-name>
❌ 17. Undo Last Commit (Soft Reset)
Remove the last commit but keep the changes.
git reset HEAD~1
🧐 18. View Changes in a Specific File
See who last modified each line of a file.
git blame <filename>
🌐 19. Check Remote Repositories
List all remote connections (useful for verifying URLs).
git remote -v
➕ 20. Add a Remote Repository
Link your local repo to a Git hosting service like GitHub.
git remote add origin <repository-url>
✅ Final Thoughts
You don’t need to memorize every Git command — just knowing these 20 essential Git basics can supercharge your daily development workflow. As you get more comfortable, you’ll discover shortcuts, tools like Git GUIs, and even advanced features like interactive rebasing and cherry-picking.
For now, keep this list handy. The more you use Git, the more second-nature it becomes.