|
Getting your Trinity Audio player ready... |
Git is one of the most important tools for developers, helping you track changes, collaborate with teams, and manage code efficiently. If you’re new to Git, learning its commands can feel overwhelming — but don’t worry.

This guide breaks down all the essential Git commands into simple categories such as General Tools, Staging/Commit, Branching, Remote, Debugging, and Stash Management. Each command is explained in plain English so you can learn faster and code confidently.
🔧 1. General Git Tools
These are the most commonly used Git commands for setting up projects and managing basic operations.
| Command | Description |
|---|---|
| git init | Initialize a new Git repository |
git clone <repo> | Clone a remote repository to your local system |
| git status | Check the status of files and the current branch |
| git log | View commit history |
| git branch | List all branches |
git checkout <b> | Switch branches |
git merge <b> | Merge a branch into the current branch |
| git stash | Temporarily save uncommitted changes |
| git stash pop | Apply stashed changes back to your working directory |
✅ 2. Basic Build (Staging & Commit)
These commands help you stage changes, commit them, and push them to the remote repo.
| Command | Description |
|---|---|
git add <file> | Stage a specific file |
| git add . | Stage all changes |
| git commit -m “message” | Commit staged changes with a message |
| git push | Push commits to a remote repository |
| git pull | Fetch + merge updates from remote |
🔍 3. Info & Debug
These commands are useful for viewing, comparing, and debugging changes.
| Command | Description |
|---|---|
| git diff | View unstaged changes |
| git diff –staged | View staged changes |
| git show | Show details of a commit |
| git tag | List tags |
git blame <file> | Show who made changes line-by-line |
🌐 4. Remote Repository Commands
These commands help you connect your local repo with remote servers like GitHub or GitLab.
| Command | Description |
|---|---|
| git remote | List remote repositories |
git remote add origin <URL> | Add a remote URL |
| git remote -v | Show remote URLs |
git push -u origin <branch> | Push and set upstream branch |
| git fetch | Download remote changes without merging |
🌿 5. Branching Commands
Branches allow you to work on new features without touching the main code.
| Command | Description |
|---|---|
git branch <name> | Create a new branch |
git checkout -b <name> | Create + switch to a new branch |
git switch <branch> | Switch branches |
git branch -d <branch> | Delete a branch |
git merge <branch> | Merge a branch into the current one |
🧹 6. Objects & Cleanup
These commands help you clean your repository and remove unnecessary files.
| Command | Description |
|---|---|
| git clean -f | Remove untracked files |
| git gc | Clean up unnecessary files & optimize repo |
| git fsck | Verify integrity of the repository |
🗂️ 7. Stash Management
Stashing helps you save your incomplete work temporarily without committing it.
| Command | Description |
|---|---|
| git stash | Save your changes |
| git stash list | View saved stashes |
| git stash apply | Apply stash without deleting it |
| git stash pop | Apply + delete stash |
| git stash drop | Delete a specific stash |
⭐ Final Thoughts
This Git commands cheat sheet is perfect for beginners, students, and even experienced developers who need quick reminders while working on projects. Git may look complex at first, but once you understand these commands, it becomes one of the most powerful tools in your development workflow.
30-Day HackerRank Coding Challenge (Complete Roadmap)
How to Learn Web Development in the Era of AI
Arsalan Malik is a passionate Software Engineer and the Founder of Makemychance.com. A proud CDAC-qualified developer, Arsalan specializes in full-stack web development, with expertise in technologies like Node.js, PHP, WordPress, React, and modern CSS frameworks.
He actively shares his knowledge and insights with the developer community on platforms like Dev.to and engages with professionals worldwide through LinkedIn.
Arsalan believes in building real-world projects that not only solve problems but also educate and empower users. His mission is to make technology simple, accessible, and impactful for everyone.

