Top Banner
← Back to Blog

Git Cheat Sheet: Essential Git Commands Every Developer Should Know

Git Cheat Sheet

Git is the most widely used version control system in the world. Whether you are managing a personal project or collaborating with a team, understanding Git commands can significantly improve productivity.

In This Guide

✓ Git Configuration
✓ Clone Repository
✓ Commit Changes
✓ Push & Pull
✓ Branches
✓ Merge
✓ Stash
✓ Reset
✓ Tags
✓ Troubleshooting

Configure Git

git config --global user.name "Your Name"
git config --global user.email "[email protected]"
git config --list

Clone Repository

git clone https://github.com/user/project.git

Check Repository Status

git status

Stage & Commit Changes

git add .
git add filename.txt
git commit -m "Initial commit"

Push Changes

git push origin main

Pull Latest Changes

git pull origin main

Branch Management

git branch
git branch feature-login
git checkout feature-login
git checkout -b feature-login

Merge Branches

git checkout main
git merge feature-login

Delete Branch

git branch -d feature-login

Git Stash

git stash
git stash list
git stash pop

Git Reset

git reset --soft HEAD~1
git reset --hard HEAD~1

Tags

git tag v1.0
git push origin v1.0

Useful Troubleshooting Commands

git log --oneline
git diff
git remote -v
git fetch --all

Git Best Practices

Commit Frequently

Small commits are easier to review and revert.

Use Branches

Keep new features isolated until ready.

Pull Before Push

Avoid merge conflicts by syncing first.

Write Clear Messages

Make commit history easier to understand.