Development
Git Cheatsheet
Find a command for the next step in a Git workflow, with attention to the working tree, staging area, and current branch.
About this tool
When to use it
Find a command for the next step in a Git workflow, with attention to the working tree, staging area, and current branch.
How to use it
Search by task, such as unstage or branch, read the explanation, and copy the matching command. Replace angle-bracket placeholders before running it in your own terminal. Check git status first so you know which repository and branch will be affected.
Guide updated . Examples checked against this implementation.
Worked examples
Unstage without discarding edits
Input
Search: Unstage a fileExpected output
git restore --staged <file>Replace <file> with the intended path. This changes the staging area while retaining working-file edits; it is different from discarding a file with git restore <file>.
Errors and unsupported input
git pull --ff-only refuses to proceedInspect the branch history: local and remote work may have diverged. Choose a merge or rebase policy before retrying rather than adding a force option.
Continue this workflow
- Text Diff: Inspect two text versions before deciding what belongs in a commit.
Format references
Questions
Frequently asked questions
Does copying a command change my repository?
No. A command has an effect only when you execute it. The page cannot see your branch, remotes, or uncommitted work.