DEV Community

Dainy Jose
Dainy Jose

Posted on

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)

git config --global user.name "Your Name"
git config --global user.email "you@example.com"
Enter fullscreen mode Exit fullscreen mode

📁 Initialize or Clone Project

git init                                       # Start a new Git repo
git clone <repo-url>                           # Clone an existing remote repo
Enter fullscreen mode Exit fullscreen mode

🌐 Set or Change Remote Repo

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
Enter fullscreen mode Exit fullscreen mode

📄 Track Changes & Make Commits

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

🚀 Push & Pull Code

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
Enter fullscreen mode Exit fullscreen mode

🌿 Branching

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
Enter fullscreen mode Exit fullscreen mode

📤 Push Workflow (Push Request)

git status
git add .
git commit -m "changes"
git push origin <your-branch>
Enter fullscreen mode Exit fullscreen mode

🔄 Pull Workflow (Pull Request)

git status
git stash -u                                   # Save all local changes
git pull origin <branch-name>
git stash apply                                # Reapply stashed changes
Enter fullscreen mode Exit fullscreen mode

🌱 Create Branch, Make Changes, Return

git checkout -b <new-branch>
# make changes
git add .
git commit -m "updated something"
git checkout <old-branch>
Enter fullscreen mode Exit fullscreen mode

📦 Push New Branch to Remote

git push --set-upstream origin <new-branch-name>
Enter fullscreen mode Exit fullscreen mode

🔃 Rebase Feature Branch with Master

git checkout <your-feature-branch>
git rebase master
Enter fullscreen mode Exit fullscreen mode

📥 Clone & Create New Branch from Another

git clone <repo-url>
cd <project-folder>
git checkout <existing-branch>
git checkout -b <new-branch>
Enter fullscreen mode Exit fullscreen mode

🔧 Utilities

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
Enter fullscreen mode Exit fullscreen mode

🎯 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!


✍️ Written by Dainy Jose — Mobile App Developer specialized in React Native and the MERN stack.

💼 Skills & Tools:

Mobile App Dev | MERN Stack | React Native | TypeScript | Redux | React.js | Node.js | MongoDB | MySQL | Express.js | REST API | JWT | Google Maps | Firebase | Jest | Agile | SDLC | Payments | Git | Bitbucket | Jira

📬 Connect with me:

🔗 LinkedIn

💻 GitHub

Top comments (0)