Menu

Git Command Finder & Cheat Sheet

Find the exact Git commands for any development workflow. Customize parameters interactively, understand execution flows, and copy commands instantly.

📁

No Task Selected

Select a Git workflow scenario from the left panel to display commands and interactive controls.

Understanding Git Lifecycle States & Workflow Stages

Git is a distributed version control system designed to track file changes across development repositories. To use Git effectively, developers must understand its four key environmental zones:

  • Working Directory: The local directory on your file system where files are created, edited, and physically updated.
  • Staging Area (Index): A preparation sandbox that caches changes marked for the next transaction commit. You add files here using git add.
  • Local Repository (HEAD): The localized database on your machine containing all recorded commit histories and branch trees.
  • Remote Repository: A hosted platform (like GitHub or GitLab) where the code is synchronized so team members can share and merge changes.

Frequently Asked Questions (FAQ)

What is the difference between git reset and git revert?
git reset rewrites history by moving the current branch pointer backward to a specific commit. The commits ahead of that target are discarded (or kept in working directory depending on flags). Do not use reset on shared public branches.

git revert is a safe alternative. It creates a brand-new commit that applies inverse modifications to undo a past commit, preserving the global history tree without deletion.
How does git merge differ from git rebase?
git merge takes changes from one branch and merges them into the current active branch via a dedicated "merge commit." This keeps history accurate to real-life event sequences.

git rebase rewrites history by taking all new commits on the active branch and moving them to the top of the target branch, producing a completely linear, clean history line.
How do I restore a commit I deleted accidentally?
As long as Git has not executed garbage collection, you can run git reflog. The reflog keeps records of every head movement (checkout, commit, pull, reset). Locate the commit hash before the deletion occurred, and run git checkout <commit-hash> or reset your branch back to it.