Git cheatsheet
The Git commands you keep forgetting, grouped by what you are trying to do.
Loading tool…
About the git cheatsheet
The Git commands worth keeping close, grouped by what you are trying to do rather than alphabetically: undoing things, branching, rebasing, stashing, inspecting history and recovering from mistakes. Filter by keyword and click any command to copy it. Where a command destroys work, the description says so.
Frequently asked questions
How do I undo a commit I already pushed?
Use git revert, which adds a commit reversing the change. Rewriting shared history with reset and force push breaks every clone that already pulled it.
I think I lost work after a hard reset. Is it gone?
Probably not. git reflog lists everywhere HEAD has been, including states no branch points at any more. Find the SHA and check it out — commits survive for weeks before garbage collection.