Sandbox99 Chronicles

Mastering Git: Your Essential Cheat Sheet

Git CheatSheet

Written by Jose Mendez

Hi, I’m Jose Mendez, the creator of sandbox99.cc. with a passion for technology and a hands-on approach to learning, I’ve spent more than fifteen years navigating the ever-evolving world of IT.

Published Jun 19, 2025

Reading Time: 3 minutes

Introduction: Navigating the Git Landscape with Ease

Git is an indispensable tool for developers, enabling version control, collaborative development, and seamless project management. However, with its vast array of commands and options, it’s easy to feel overwhelmed. That’s where a trusty Git cheat sheet comes in! This isn’t just a list of commands; it’s your personalized guide to navigate the Git landscape efficiently, ensuring you spend less time recalling syntax and more time building amazing things.

Git Cheat Sheet: Your Go-To Commands

Here’s a curated list of essential Git commands, categorized for quick reference.

1. Getting Started & Configuration


git init
# Initializes a new Git repository in the current directory.

git clone [url]
# Creates a local copy of a remote repository.

git config --global user.name "Your Name"
# Sets your global username for Git commits.

git config --global user.email "your_email@example.com"
# Sets your global email for Git commits.

2. Staging & Committing Changes


git status
# Shows the status of changes as untracked, modified, or staged.

git add [file]
# Stages a specific file for the next commit.

git add .
# Stages all changes in the current directory.

git reset [file]
# Unstages a specific file.

git commit -m "Your commit message"
# Records staged changes with a descriptive message.

git commit -am "Your commit message"
# Stages all modified and deleted files, then commits them (skips git add for tracked files).

3. Branching & Merging


git branch
# Lists all local branches.

git branch [branch-name]
# Creates a new branch.

git checkout [branch-name]
# Switches to a different branch.

git checkout -b [new-branch-name]
# Creates a new branch and switches to it.

git merge [branch-name]
# Merges the specified branch into the current branch.

git branch -d [branch-name]
# Deletes a local branch (only if merged).

git push origin --delete [branch-name]
# Deletes a remote branch.

4. Remote Operations | Share & Update


git remote -v
# Lists all remote repositories.

git fetch origin
# Downloads objects and refs from another repository.

git merge [alias]/[branch]
# Merge a remote branch into your current branch to bring it up to date

git remote add origin [url]
# Adds a new remote repository named origin.

git push origin [branch-name]
# Pushes local commits to a remote branch.

git pull origin [branch-name]
# Fetches and merges changes from a remote branch.

5. Inspecting History & Undoing Changes


git log
# Shows the commit history.

git log --oneline
# Shows a concise commit history.

git diff
# Shows unstaged changes.

git diff --staged
# Shows staged changes.

git reset --hard [commit-hash]
# Discards all changes and reverts to a specific commit (USE WITH CAUTION!).

git revert [commit-hash]
# Creates a new commit that undoes the changes from a previous commit.

6. Stashing Changes | Temporary Commits


git stash
# Temporarily shelves (or stashes) changes you've made to your working copy.

git stash list
# Lists all stashes.

git stash apply
# Reapplies the most recent stash without removing it from the stash list.

git stash pop
# Reapplies the most recent stash and removes it from the stash list.

git stash drop
# Deletes the most recent stash.

7. Tracking Path Changes


git rm [file]
# Delete the file from project and stage the removal for commit

git mv [existing-path] [new-path]
# Change an existing file path and stage the move

git log --stat -M
# Show all commit logs with indication of any paths that moved

Why You Should Keep Your Own Git Cheat Sheet

You might be thinking, “Why bother creating my own cheat sheet when there are so many online?” Here’s why a personalized Git cheat sheet is invaluable:

  1. Personalized Efficiency: You’ll tailor it to the commands you use most frequently, making it a hyper-efficient reference for your workflow.
  2. Quick Recall: Instead of searching the web every time you forget a specific flag or sequence, a quick glance at your cheat sheet will jog your memory.
  3. Learning Reinforcement: The act of creating and organizing your cheat sheet reinforces your understanding of Git commands and their usage.
  4. Problem Solving: When you encounter a specific Git problem, having a quick reference can help you troubleshoot and find the right command more rapidly.
  5. Reduced Context Switching: Staying within your development environment and having a readily available cheat sheet minimizes interruptions, allowing you to maintain your flow.
  6. Evolving Resource: As you learn new Git tricks or encounter new scenarios, you can continuously update your cheat sheet, making it a living document that grows with your expertise.

In conclusion, while Git can seem daunting at first, a well-organized and personalized cheat sheet is a powerful tool that will boost your productivity and confidence. Start building yours today, and happy Gitting!

Related Post

Caddy: The Modern Web Server You Need to Know

Caddy: The Modern Web Server You Need to Know

The Shifting Landscape of Web Servers For years, a few titans have dominated the web server landscape. Names like Nginx, Apache2, and Microsoft IIS have been synonymous with hosting websites and applications, powering the vast majority of the internet. Their robust...

read more