Git

Git Complete Commands Cheat Sheet for Developers

September 15, 2025•3 min read•3 views
Git

StackQuill

Git Complete Commands Cheat Sheet for Developers

Git is one of the most essential tools in a developer’s workflow. Whether you’re working on solo projects or collaborating in a team, having the right Git commands at your fingertips can save time and avoid mistakes.

Here’s a complete Git commands cheat sheet you can bookmark for quick reference 🚀.


🔧 Set Git Global Config (Only once per machine)

bash
git config --global user.name "Your Name"
git config --global user.email "you@example.com"

📁 Initialize or Clone Project

bash
git init                                       # Start a new Git repo
git clone <repo-url>                           # Clone an existing remote repo

🌐 Set or Change Remote Repo

bash
git remote add origin <repo-url>               # Add remote repo
git remote set-url origin <new-url>            # Change existing remote
git remote -v                                  # View current remotes

📄 Track Changes & Make Commits

bash
git status                                     # Show current changes
git add .                                      # Stage all changes
git add <file>                                 # Stage specific file
git commit -m "your message"                   # Commit staged changes

🚀 Push & Pull Code

bash
git push                                       # Push to default remote
git push -u origin main                        # First push and set upstream
git push origin <branch-name>                  # Push specific branch
git pull                                       # Pull latest from remote
git pull origin <branch-name>                  # Pull from specific branch

🌿 Branching

bash
git branch                                     # List all branches
git branch <branch-name>                       # Create new branch
git checkout <branch-name>                     # Switch to branch
git checkout -b <branch-name>                  # Create & switch branch
git merge <branch-name>                        # Merge into current branch

📤 Push Workflow (Push Request)

bash
git status
git add .
git commit -m "changes"
git push origin <your-branch>

🔄 Pull Workflow (Pull Request)

bash
git status
git stash -u                                   # Save all local changes
git pull origin <branch-name>
git stash apply                                # Reapply stashed changes

🌱 Create Branch, Make Changes, Return

bash
git checkout -b <new-branch>
# make changes
git add .
git commit -m "updated something"
git checkout <old-branch>

📦 Push New Branch to Remote

bash
git push --set-upstream origin <new-branch-name>

🔃 Rebase Feature Branch with Master

bash
git checkout <your-feature-branch>
git rebase master

📥 Clone & Create New Branch from Another

bash
git clone <repo-url>
cd <project-folder>
git checkout <existing-branch>
git checkout -b <new-branch>

🔧 Utilities

bash
git stash                                       # Temporarily save changes
git stash pop                                   # Reapply stashed changes
git log                                         # View commit history
git reset <file>                                # Unstage a file
git rm <file>                                   # Remove file from Git & disk

🎯 Final Thoughts

Git can feel overwhelming when you’re just getting started, but once you memorize the core commands, it becomes second nature. This cheat sheet is designed to cover the most common and practical Git workflows that every developer needs.

👉 Save this, share with your team, and level up your Git game!