|
Initial Commit
| https://www.programmergate.com/ |
| HOME | https://www.programmergate.com/ |
| EXPLORE | https://www.programmergate.com/learn/git/animated-cheat-sheet |
| Animated Git Cheat Sheet | https://www.programmergate.com/learn/git/animated-cheat-sheet |
| Visual Git command reference | https://www.programmergate.com/learn/git/visual-command-reference |
| Git command demos | https://www.programmergate.com/tools/git-sim/viewer#commands |
| LEARN | https://www.programmergate.com/learn/git |
| Git lessons | https://www.programmergate.com/learn/git |
| Git workflow demos | https://www.programmergate.com/tools/git-sim/viewer#workflows |
| Git commands | https://www.programmergate.com/learn/git/commands |
| Git articles | https://www.programmergate.com/learn/git/articles |
| Git basics | https://www.programmergate.com/learn/git/basics |
| Working with a team | https://www.programmergate.com/learn/git/team |
| Getting unstuck | https://www.programmergate.com/learn/git/rescue |
| All Git topics | https://www.programmergate.com/learn/git/topics |
| Python | https://www.programmergate.com/cluster/python |
| Java | https://www.programmergate.com/cluster/java |
| Amazon Web Services (AWS) | https://www.programmergate.com/cluster/amazon-web-services-aws |
| Spring Boot | https://www.programmergate.com/cluster/spring-boot |
| General Programming | https://www.programmergate.com/cluster/general-programming |
| History of Programming | https://www.programmergate.com/cluster/history-of-programming |
| JavaScript & Node.js | https://www.programmergate.com/cluster/javascript |
| Vim | https://www.programmergate.com/cluster/vim |
| DEVELOP | https://www.programmergate.com/tools |
| git-sim | https://www.programmergate.com/tools/git-sim |
| git-sim viewer | https://www.programmergate.com/tools/git-sim/viewer |
| git-sim live | https://www.programmergate.com/tools/git-sim#live |
| git-sim agentic | https://www.programmergate.com/tools/git-sim#agents |
| git-sim → VS Code | https://www.programmergate.com/tools/git-sim#vscode |
| git-dummy | https://www.programmergate.com/tools/git-dummy |
| Devlands | https://devlands.com |
| All tools | https://www.programmergate.com/tools |
| BOOKS | https://www.programmergate.com/store?type=book |
| BLOG | https://www.programmergate.com/blog |
| ABOUT | https://www.programmergate.com/about |
| CONTACT | https://www.programmergate.com/contact |
| Blog RSS | https://www.programmergate.com/blog/rss.xml |
| For explorers ↓ | https://www.programmergate.com#explore |
| For learners ↓ | https://www.programmergate.com#learn |
| For developers ↓ | https://www.programmergate.com#develop |
| git-sim | https://initialcommit.com/tools/git-sim |
| Learn Git | https://initialcommit.com/learn/git |
| post the private link | https://www.programmergate.com |
| X | https://www.programmergate.com |
| Bluesky | https://www.programmergate.com |
| LinkedIn | https://www.programmergate.com |
| Reddit | https://www.programmergate.com |
| Hacker News | https://www.programmergate.com |
| Email | https://www.programmergate.com |
| The Animated Git Cheat SheetFree · Customize it · Download it · Print it→ | https://initialcommit.com/learn/git/animated-cheat-sheet?ref=git-sim-help |
| git-sim | https://www.programmergate.com/tools/git-sim |
| git-sim | https://www.programmergate.com/tools/git-sim |
| Open the cheat sheet | https://www.programmergate.com/learn/git/animated-cheat-sheet |
|
Create a new repository
Safe
$ git init
Start a project
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-start |
|
Delete a file and stage the deletion
Caution
$ git rm
Manage files
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-files |
|
Delete all untracked files
Destructive
$ git clean -f
Manage files
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-files |
|
Clone a repository
Safe
$ git clone
Start a project
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-start |
|
Abort a merge with conflicts
Caution
$ git merge --abort
Merge
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-merge |
|
Delete all untracked and ignored files
Destructive
$ git clean -fdx
Manage files
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-files |
|
Clone only the N latest commits
Safe
$ git clone --depth
Start a project
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-start |
|
Rebase the active branch onto another
Caution
$ git rebase
Rebase and cherry-pick
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-rebase |
|
Force-delete an unmerged branch
Destructive
$ git branch -D
Branches
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-branches |
|
Clone a repository and check out a specific branch
Safe
$ git clone -b
Start a project
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-start |
|
Run an interactive rebase to edit, squash, or reorder commits
Caution
$ git rebase -i
Rebase and cherry-pick
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-rebase |
|
Force-push and overwrite the remote branch
Destructive
$ git push --force
Fetch, pull, and push
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-sync |
|
Set your author name
Safe
$ git config --global user.name ""
Configure Git
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-configure |
|
Move part of a branch onto a new base commit
Caution
$ git rebase --onto
Rebase and cherry-pick
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-rebase |
|
Delete a remote branch
Destructive
$ git push origin --delete
Fetch, pull, and push
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-sync |
|
Set your email address
Safe
$ git config --global user.email ""
Configure Git
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-configure |
|
Skip the conflicting commit in a rebase
Caution
$ git rebase --skip
Rebase and cherry-pick
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-rebase |
|
Delete all stash entries
Destructive
$ git stash clear
Stash
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-stash |
|
Set your default branch name
Safe
$ git config --global init.defaultBranch
Configure Git
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-configure |
|
Abort a rebase in progress
Caution
$ git rebase --abort
Rebase and cherry-pick
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-rebase |
|
Discard unstaged changes to a file
Destructive
$ git restore
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Set your text editor
Safe
$ git config --global core.editor ""
Configure Git
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-configure |
|
Remove a remote
Caution
$ git remote remove
Remotes
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-remotes |
|
Discard all unstaged changes
Destructive
$ git restore .
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
List all config settings
Safe
$ git config --list
Configure Git
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-configure |
|
Pull and rebase instead of merging
Caution
$ git pull --rebase
Fetch, pull, and push
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-sync |
|
Discard all unstaged changes (older Git)
Destructive
$ git checkout -- .
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Set a setting for every user on the machine
Safe
$ git config --system
Configure Git
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-configure |
|
Force-push only if the remote branch hasn't changed
Caution
$ git push --force-with-lease
Fetch, pull, and push
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-sync |
|
Restore a file from an older commit
Destructive
$ git restore --source
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Create a shortcut for a command
Safe
$ git config --global alias.
Configure Git
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-configure |
|
Delete a local tag
Caution
$ git tag -d
Tags
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-tags |
|
Reset the branch and discard all changes
Destructive
$ git reset --hard
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Rebase instead of merging when you pull
Safe
$ git config --global pull.rebase true
Configure Git
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-configure |
|
Delete a remote tag
Caution
$ git push origin --delete
Tags
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-tags |
|
Reset your branch to match the remote
Destructive
$ git reset --hard origin/
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Prune deleted remote branches on every fetch
Safe
$ git config --global fetch.prune true
Configure Git
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-configure |
|
Drop a stash entry
Caution
$ git stash drop
Stash
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-stash |
|
Undo a hard reset
Destructive
$ git reset --hard HEAD@{1}
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Convert line endings on Windows
Safe
$ git config --global core.autocrlf true
Configure Git
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-configure |
|
Amend the last commit
Caution
$ git commit --amend -m ""
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Delete all untracked files
Destructive
$ git clean -f
Manage files
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-files |
|
Save your Git credentials
Safe
$ git config --global credential.helper
Configure Git
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-configure |
|
Undo the N latest commits, keep their changes staged
Caution
$ git reset --soft HEAD~
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Delete all untracked and ignored files
Destructive
$ git clean -fdx
Manage files
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-files |
|
Check the state of your repository
Safe
$ git status
Stage and commit
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-commit |
|
Undo the N latest commits, keep their changes unstaged
Caution
$ git reset HEAD~
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Force-delete an unmerged branch
Destructive
$ git branch -D
Branches
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-branches |
|
Stage your file changes
Safe
$ git add
Stage and commit
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-commit |
|
Delete a file and stage the deletion
Caution
$ git rm
Manage files
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-files |
|
Force-push and overwrite the remote branch
Destructive
$ git push --force
Fetch, pull, and push
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-sync |
|
Stage all changes in the current folder
Safe
$ git add .
Stage and commit
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-commit |
|
Abort a merge with conflicts
Caution
$ git merge --abort
Merge
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-merge |
|
Delete a remote branch
Destructive
$ git push origin --delete
Fetch, pull, and push
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-sync |
|
Stage all changes in the repository
Safe
$ git add -A
Stage and commit
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-commit |
|
Rebase the active branch onto another
Caution
$ git rebase
Rebase and cherry-pick
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-rebase |
|
Delete all stash entries
Destructive
$ git stash clear
Stash
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-stash |
|
Commit your staged changes
Safe
$ git commit -m ""
Stage and commit
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-commit |
|
Run an interactive rebase to edit, squash, or reorder commits
Caution
$ git rebase -i
Rebase and cherry-pick
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-rebase |
|
Discard unstaged changes to a file
Destructive
$ git restore
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Stage and commit tracked file changes in one command
Safe
$ git commit -am ""
Stage and commit
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-commit |
|
Move part of a branch onto a new base commit
Caution
$ git rebase --onto
Rebase and cherry-pick
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-rebase |
|
Discard all unstaged changes
Destructive
$ git restore .
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Stop tracking a file but keep it on disk
Safe
$ git rm --cached
Manage files
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-files |
|
Skip the conflicting commit in a rebase
Caution
$ git rebase --skip
Rebase and cherry-pick
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-rebase |
|
Discard all unstaged changes (older Git)
Destructive
$ git checkout -- .
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Rename or move a file
Safe
$ git mv
Manage files
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-files |
|
Abort a rebase in progress
Caution
$ git rebase --abort
Rebase and cherry-pick
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-rebase |
|
Restore a file from an older commit
Destructive
$ git restore --source
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Find the rule that ignores a file
Safe
$ git check-ignore -v
Manage files
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-files |
|
Remove a remote
Caution
$ git remote remove
Remotes
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-remotes |
|
Reset the branch and discard all changes
Destructive
$ git reset --hard
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
View the active branch's commit history
Safe
$ git log
History and search
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-history |
|
Pull and rebase instead of merging
Caution
$ git pull --rebase
Fetch, pull, and push
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-sync |
|
Reset your branch to match the remote
Destructive
$ git reset --hard origin/
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
View the commit history of all branches
Safe
$ git log --all
History and search
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-history |
|
Force-push only if the remote branch hasn't changed
Caution
$ git push --force-with-lease
Fetch, pull, and push
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-sync |
|
Undo a hard reset
Destructive
$ git reset --hard HEAD@{1}
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
View all branches as a text graph
Safe
$ git log --oneline --graph --all
History and search
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-history |
|
Delete a local tag
Caution
$ git tag -d
Tags
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-tags |
|
Delete all untracked files
Destructive
$ git clean -f
Manage files
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-files |
|
View every change to a file, commit by commit
Safe
$ git log -p
History and search
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-history |
|
Delete a remote tag
Caution
$ git push origin --delete
Tags
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-tags |
|
Delete all untracked and ignored files
Destructive
$ git clean -fdx
Manage files
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-files |
|
Follow a file's history through renames
Safe
$ git log --follow
History and search
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-history |
|
Drop a stash entry
Caution
$ git stash drop
Stash
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-stash |
|
Force-delete an unmerged branch
Destructive
$ git branch -D
Branches
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-branches |
|
Find the commits that added or removed a string
Safe
$ git log -S ""
History and search
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-history |
|
Amend the last commit
Caution
$ git commit --amend -m ""
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Force-push and overwrite the remote branch
Destructive
$ git push --force
Fetch, pull, and push
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-sync |
|
List one author's commits
Safe
$ git log --author ""
History and search
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-history |
|
Undo the N latest commits, keep their changes staged
Caution
$ git reset --soft HEAD~
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Delete a remote branch
Destructive
$ git push origin --delete
Fetch, pull, and push
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-sync |
|
List the commits from a date range
Safe
$ git log --since "" --until ""
History and search
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-history |
|
Undo the N latest commits, keep their changes unstaged
Caution
$ git reset HEAD~
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Delete all stash entries
Destructive
$ git stash clear
Stash
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-stash |
|
View a commit's data
Safe
$ git show
History and search
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-history |
|
Delete a file and stage the deletion
Caution
$ git rm
Manage files
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-files |
|
Discard unstaged changes to a file
Destructive
$ git restore
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
See who last changed each line of a file
Safe
$ git blame
History and search
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-history |
|
Abort a merge with conflicts
Caution
$ git merge --abort
Merge
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-merge |
|
Discard all unstaged changes
Destructive
$ git restore .
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Count commits by author
Safe
$ git shortlog -sn
History and search
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-history |
|
Rebase the active branch onto another
Caution
$ git rebase
Rebase and cherry-pick
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-rebase |
|
Discard all unstaged changes (older Git)
Destructive
$ git checkout -- .
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Describe a commit by its nearest tag
Safe
$ git describe
History and search
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-history |
|
Run an interactive rebase to edit, squash, or reorder commits
Caution
$ git rebase -i
Rebase and cherry-pick
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-rebase |
|
Restore a file from an older commit
Destructive
$ git restore --source
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Search all tracked files for text
Safe
$ git grep -n ""
History and search
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-history |
|
Move part of a branch onto a new base commit
Caution
$ git rebase --onto
Rebase and cherry-pick
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-rebase |
|
Reset the branch and discard all changes
Destructive
$ git reset --hard
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Find the commit that introduced a bug
Safe
$ git bisect start
History and search
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-history |
|
Skip the conflicting commit in a rebase
Caution
$ git rebase --skip
Rebase and cherry-pick
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-rebase |
|
Reset your branch to match the remote
Destructive
$ git reset --hard origin/
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Show unstaged changes
Safe
$ git diff
Compare changes
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-compare |
|
Abort a rebase in progress
Caution
$ git rebase --abort
Rebase and cherry-pick
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-rebase |
|
Undo a hard reset
Destructive
$ git reset --hard HEAD@{1}
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Show staged changes
Safe
$ git diff --staged
Compare changes
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-compare |
|
Remove a remote
Caution
$ git remote remove
Remotes
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-remotes |
|
Delete all untracked files
Destructive
$ git clean -f
Manage files
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-files |
|
Compare two commits
Safe
$ git diff
Compare changes
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-compare |
|
Pull and rebase instead of merging
Caution
$ git pull --rebase
Fetch, pull, and push
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-sync |
|
Delete all untracked and ignored files
Destructive
$ git clean -fdx
Manage files
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-files |
|
Compare two branches
Safe
$ git diff ..
Compare changes
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-compare |
|
Force-push only if the remote branch hasn't changed
Caution
$ git push --force-with-lease
Fetch, pull, and push
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-sync |
|
Force-delete an unmerged branch
Destructive
$ git branch -D
Branches
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-branches |
|
Summarize the changes per file
Safe
$ git diff --stat
Compare changes
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-compare |
|
Delete a local tag
Caution
$ git tag -d
Tags
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-tags |
|
Force-push and overwrite the remote branch
Destructive
$ git push --force
Fetch, pull, and push
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-sync |
|
Create a new branch without switching to it
Safe
$ git branch
Branches
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-branches |
|
Delete a remote tag
Caution
$ git push origin --delete
Tags
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-tags |
|
Delete a remote branch
Destructive
$ git push origin --delete
Fetch, pull, and push
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-sync |
|
List all local and remote-tracking branches
Safe
$ git branch -a
Branches
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-branches |
|
Drop a stash entry
Caution
$ git stash drop
Stash
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-stash |
|
Delete all stash entries
Destructive
$ git stash clear
Stash
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-stash |
|
List branches with their upstream and ahead/behind counts
Safe
$ git branch -vv
Branches
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-branches |
|
Amend the last commit
Caution
$ git commit --amend -m ""
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Discard unstaged changes to a file
Destructive
$ git restore
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
List branches already merged into the active branch
Safe
$ git branch --merged
Branches
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-branches |
|
Undo the N latest commits, keep their changes staged
Caution
$ git reset --soft HEAD~
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Discard all unstaged changes
Destructive
$ git restore .
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
List branches not yet merged into the active branch
Safe
$ git branch --no-merged
Branches
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-branches |
|
Undo the N latest commits, keep their changes unstaged
Caution
$ git reset HEAD~
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Discard all unstaged changes (older Git)
Destructive
$ git checkout -- .
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Switch to another branch
Safe
$ git switch
Branches
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-branches |
|
Delete a file and stage the deletion
Caution
$ git rm
Manage files
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-files |
|
Restore a file from an older commit
Destructive
$ git restore --source
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Switch back to the previous branch
Safe
$ git switch -
Branches
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-branches |
|
Abort a merge with conflicts
Caution
$ git merge --abort
Merge
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-merge |
|
Reset the branch and discard all changes
Destructive
$ git reset --hard
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Check out a branch from the remote
Safe
$ git switch
Branches
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-branches |
|
Rebase the active branch onto another
Caution
$ git rebase
Rebase and cherry-pick
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-rebase |
|
Reset your branch to match the remote
Destructive
$ git reset --hard origin/
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Create a new branch and switch to it
Safe
$ git switch -c
Branches
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-branches |
|
Run an interactive rebase to edit, squash, or reorder commits
Caution
$ git rebase -i
Rebase and cherry-pick
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-rebase |
|
Undo a hard reset
Destructive
$ git reset --hard HEAD@{1}
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Create a new branch at a specific commit and switch to it
Safe
$ git switch -c
Branches
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-branches |
|
Move part of a branch onto a new base commit
Caution
$ git rebase --onto
Rebase and cherry-pick
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-rebase |
|
Delete all untracked files
Destructive
$ git clean -f
Manage files
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-files |
|
Rename a branch
Safe
$ git branch -m
Branches
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-branches |
|
Skip the conflicting commit in a rebase
Caution
$ git rebase --skip
Rebase and cherry-pick
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-rebase |
|
Delete all untracked and ignored files
Destructive
$ git clean -fdx
Manage files
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-files |
|
Delete a merged branch
Safe
$ git branch -d
Branches
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-branches |
|
Abort a rebase in progress
Caution
$ git rebase --abort
Rebase and cherry-pick
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-rebase |
|
Force-delete an unmerged branch
Destructive
$ git branch -D
Branches
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-branches |
|
Check out a non-branch commit (detached HEAD)
Safe
$ git switch --detach
Branches
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-branches |
|
Remove a remote
Caution
$ git remote remove
Remotes
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-remotes |
|
Force-push and overwrite the remote branch
Destructive
$ git push --force
Fetch, pull, and push
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-sync |
|
Merge a branch into the active branch
Safe
$ git merge
Merge
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-merge |
|
Pull and rebase instead of merging
Caution
$ git pull --rebase
Fetch, pull, and push
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-sync |
|
Delete a remote branch
Destructive
$ git push origin --delete
Fetch, pull, and push
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-sync |
|
Fast-forward the active branch
Safe
$ git merge
Merge
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-merge |
|
Force-push only if the remote branch hasn't changed
Caution
$ git push --force-with-lease
Fetch, pull, and push
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-sync |
|
Delete all stash entries
Destructive
$ git stash clear
Stash
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-stash |
|
Force a merge commit even if a fast-forward merge is possible
Safe
$ git merge --no-ff
Merge
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-merge |
|
Delete a local tag
Caution
$ git tag -d
Tags
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-tags |
|
Discard unstaged changes to a file
Destructive
$ git restore
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Squash a branch's changes into one commit
Safe
$ git merge --squash
Merge
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-merge |
|
Delete a remote tag
Caution
$ git push origin --delete
Tags
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-tags |
|
Discard all unstaged changes
Destructive
$ git restore .
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Finish a merge after fixing conflicts
Safe
$ git merge --continue
Merge
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-merge |
|
Drop a stash entry
Caution
$ git stash drop
Stash
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-stash |
|
Discard all unstaged changes (older Git)
Destructive
$ git checkout -- .
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Continue a rebase after fixing conflicts
Safe
$ git rebase --continue
Rebase and cherry-pick
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-rebase |
|
Amend the last commit
Caution
$ git commit --amend -m ""
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Restore a file from an older commit
Destructive
$ git restore --source
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Apply a commit from another branch to the active branch
Safe
$ git cherry-pick
Rebase and cherry-pick
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-rebase |
|
Undo the N latest commits, keep their changes staged
Caution
$ git reset --soft HEAD~
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Reset the branch and discard all changes
Destructive
$ git reset --hard
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Apply a range of commits from another branch to the active branch
Safe
$ git cherry-pick ..
Rebase and cherry-pick
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-rebase |
|
Undo the N latest commits, keep their changes unstaged
Caution
$ git reset HEAD~
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Reset your branch to match the remote
Destructive
$ git reset --hard origin/
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Add a new remote
Safe
$ git remote add
Remotes
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-remotes |
|
Delete a file and stage the deletion
Caution
$ git rm
Manage files
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-files |
|
Undo a hard reset
Destructive
$ git reset --hard HEAD@{1}
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
List remotes with their URLs
Safe
$ git remote -v
Remotes
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-remotes |
|
Abort a merge with conflicts
Caution
$ git merge --abort
Merge
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-merge |
|
Delete all untracked files
Destructive
$ git clean -f
Manage files
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-files |
|
Show the details of a remote
Safe
$ git remote show
Remotes
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-remotes |
|
Rebase the active branch onto another
Caution
$ git rebase
Rebase and cherry-pick
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-rebase |
|
Delete all untracked and ignored files
Destructive
$ git clean -fdx
Manage files
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-files |
|
Change a remote's URL
Safe
$ git remote set-url
Remotes
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-remotes |
|
Run an interactive rebase to edit, squash, or reorder commits
Caution
$ git rebase -i
Rebase and cherry-pick
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-rebase |
|
Force-delete an unmerged branch
Destructive
$ git branch -D
Branches
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-branches |
|
Rename a remote
Safe
$ git remote rename
Remotes
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-remotes |
|
Move part of a branch onto a new base commit
Caution
$ git rebase --onto
Rebase and cherry-pick
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-rebase |
|
Force-push and overwrite the remote branch
Destructive
$ git push --force
Fetch, pull, and push
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-sync |
|
List a remote's branches and tags without fetching
Safe
$ git ls-remote
Remotes
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-remotes |
|
Skip the conflicting commit in a rebase
Caution
$ git rebase --skip
Rebase and cherry-pick
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-rebase |
|
Delete a remote branch
Destructive
$ git push origin --delete
Fetch, pull, and push
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-sync |
|
Set the upstream branch of the active branch
Safe
$ git branch -u origin/
Remotes
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-remotes |
|
Abort a rebase in progress
Caution
$ git rebase --abort
Rebase and cherry-pick
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-rebase |
|
Delete all stash entries
Destructive
$ git stash clear
Stash
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-stash |
|
Fetch new commits from the remote, without merging
Safe
$ git fetch
Fetch, pull, and push
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-sync |
|
Remove a remote
Caution
$ git remote remove
Remotes
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-remotes |
|
Discard unstaged changes to a file
Destructive
$ git restore
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Fetch new commits on one branch from a remote
Safe
$ git fetch
Fetch, pull, and push
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-sync |
|
Pull and rebase instead of merging
Caution
$ git pull --rebase
Fetch, pull, and push
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-sync |
|
Discard all unstaged changes
Destructive
$ git restore .
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Fetch new commits on all branches from all remotes
Safe
$ git fetch --all
Fetch, pull, and push
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-sync |
|
Force-push only if the remote branch hasn't changed
Caution
$ git push --force-with-lease
Fetch, pull, and push
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-sync |
|
Discard all unstaged changes (older Git)
Destructive
$ git checkout -- .
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Fetch and prune deleted remote branches
Safe
$ git fetch --prune
Fetch, pull, and push
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-sync |
|
Delete a local tag
Caution
$ git tag -d
Tags
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-tags |
|
Restore a file from an older commit
Destructive
$ git restore --source
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Fetch and merge remote commits
Safe
$ git pull
Fetch, pull, and push
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-sync |
|
Delete a remote tag
Caution
$ git push origin --delete
Tags
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-tags |
|
Reset the branch and discard all changes
Destructive
$ git reset --hard
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Pull a specific branch from the remote
Safe
$ git pull origin
Fetch, pull, and push
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-sync |
|
Drop a stash entry
Caution
$ git stash drop
Stash
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-stash |
|
Reset your branch to match the remote
Destructive
$ git reset --hard origin/
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Push the active branch's commits
Safe
$ git push
Fetch, pull, and push
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-sync |
|
Amend the last commit
Caution
$ git commit --amend -m ""
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Undo a hard reset
Destructive
$ git reset --hard HEAD@{1}
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Push a new branch and set its upstream
Safe
$ git push -u origin
Fetch, pull, and push
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-sync |
|
Undo the N latest commits, keep their changes staged
Caution
$ git reset --soft HEAD~
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Delete all untracked files
Destructive
$ git clean -f
Manage files
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-files |
|
Create a lightweight tag
Safe
$ git tag
Tags
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-tags |
|
Undo the N latest commits, keep their changes unstaged
Caution
$ git reset HEAD~
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Delete all untracked and ignored files
Destructive
$ git clean -fdx
Manage files
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-files |
|
Create an annotated tag with a message
Safe
$ git tag -a -m ""
Tags
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-tags |
|
Delete a file and stage the deletion
Caution
$ git rm
Manage files
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-files |
|
Force-delete an unmerged branch
Destructive
$ git branch -D
Branches
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-branches |
|
List all tags
Safe
$ git tag -l
Tags
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-tags |
|
Abort a merge with conflicts
Caution
$ git merge --abort
Merge
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-merge |
|
Force-push and overwrite the remote branch
Destructive
$ git push --force
Fetch, pull, and push
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-sync |
|
Push a single tag
Safe
$ git push origin
Tags
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-tags |
|
Rebase the active branch onto another
Caution
$ git rebase
Rebase and cherry-pick
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-rebase |
|
Delete a remote branch
Destructive
$ git push origin --delete
Fetch, pull, and push
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-sync |
|
Push all tags
Safe
$ git push --tags
Tags
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-tags |
|
Run an interactive rebase to edit, squash, or reorder commits
Caution
$ git rebase -i
Rebase and cherry-pick
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-rebase |
|
Delete all stash entries
Destructive
$ git stash clear
Stash
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-stash |
|
Stash your uncommitted changes
Safe
$ git stash
Stash
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-stash |
|
Move part of a branch onto a new base commit
Caution
$ git rebase --onto
Rebase and cherry-pick
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-rebase |
|
Discard unstaged changes to a file
Destructive
$ git restore
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Stash changes including untracked files
Safe
$ git stash -u
Stash
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-stash |
|
Skip the conflicting commit in a rebase
Caution
$ git rebase --skip
Rebase and cherry-pick
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-rebase |
|
Discard all unstaged changes
Destructive
$ git restore .
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Stash changes with a message
Safe
$ git stash push -m ""
Stash
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-stash |
|
Abort a rebase in progress
Caution
$ git rebase --abort
Rebase and cherry-pick
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-rebase |
|
Discard all unstaged changes (older Git)
Destructive
$ git checkout -- .
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Stash changes to a specific file or file(s)
Safe
$ git stash push
Stash
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-stash |
|
Remove a remote
Caution
$ git remote remove
Remotes
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-remotes |
|
Restore a file from an older commit
Destructive
$ git restore --source
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
List all stash entries
Safe
$ git stash list
Stash
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-stash |
|
Pull and rebase instead of merging
Caution
$ git pull --rebase
Fetch, pull, and push
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-sync |
|
Reset the branch and discard all changes
Destructive
$ git reset --hard
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Apply and drop the latest stash entry
Safe
$ git stash pop
Stash
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-stash |
|
Force-push only if the remote branch hasn't changed
Caution
$ git push --force-with-lease
Fetch, pull, and push
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-sync |
|
Reset your branch to match the remote
Destructive
$ git reset --hard origin/
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Apply the latest stash entry and keep it
Safe
$ git stash apply
Stash
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-stash |
|
Delete a local tag
Caution
$ git tag -d
Tags
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-tags |
|
Undo a hard reset
Destructive
$ git reset --hard HEAD@{1}
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Show the changes in a stash entry
Safe
$ git stash show -p
Stash
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-stash |
|
Delete a remote tag
Caution
$ git push origin --delete
Tags
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-tags |
|
Delete all untracked files
Destructive
$ git clean -f
Manage files
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-files |
|
Create a new branch from a stash entry
Safe
$ git stash branch
Stash
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-stash |
|
Drop a stash entry
Caution
$ git stash drop
Stash
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-stash |
|
Delete all untracked and ignored files
Destructive
$ git clean -fdx
Manage files
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-files |
|
Unstage a file's changes
Safe
$ git restore --staged
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Amend the last commit
Caution
$ git commit --amend -m ""
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Force-delete an unmerged branch
Destructive
$ git branch -D
Branches
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-branches |
|
Revert a commit with a new commit
Safe
$ git revert
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Undo the N latest commits, keep their changes staged
Caution
$ git reset --soft HEAD~
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Force-push and overwrite the remote branch
Destructive
$ git push --force
Fetch, pull, and push
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-sync |
|
Revert a merge commit
Safe
$ git revert -m 1
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Undo the N latest commits, keep their changes unstaged
Caution
$ git reset HEAD~
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Delete a remote branch
Destructive
$ git push origin --delete
Fetch, pull, and push
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-sync |
|
Revert several commits in one commit
Safe
$ git revert --no-commit ..
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Delete a file and stage the deletion
Caution
$ git rm
Manage files
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-files |
|
Delete all stash entries
Destructive
$ git stash clear
Stash
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-stash |
|
Find a lost commit in the reflog
Safe
$ git reflog
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Abort a merge with conflicts
Caution
$ git merge --abort
Merge
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-merge |
|
Discard unstaged changes to a file
Destructive
$ git restore
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Restore a deleted branch
Safe
$ git branch
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
|
Rebase the active branch onto another
Caution
$ git rebase
Rebase and cherry-pick
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-rebase |
|
Discard all unstaged changes
Destructive
$ git restore .
Undo and recover
| https://www.programmergate.com/learn/git/animated-cheat-sheet#cs-undo |
| Start level 1 | https://www.programmergate.com/learn/git |
|
| https://www.programmergate.com/learn/git |
| Try git-sim | https://www.programmergate.com/tools/git-sim |
| https://www.programmergate.com/tools/git-sim/viewer |
| Open the git-sim web viewer | https://www.programmergate.com/tools/git-sim/viewer |
| https://www.programmergate.com/tools/git-sim#live |
| Try git-sim live mode | https://www.programmergate.com/tools/git-sim#live |
|
agent · wants to run
$ git reset --hard HEAD~2
DESTRUCTIVE git-sim pre-flight
Moves main from 8c02d5b to 96c4fc2 (hard reset).
Would lose:
2 commits removed from branch main
staged changes in README.md (NOT recoverable)
unstaged changes in app.py (NOT recoverable)
Recover: commits stay in the reflog ~90 days
Allow this command? [y/N]
| https://www.programmergate.com/tools/git-sim#preflight |
| Check out git-sim pre-flight | https://www.programmergate.com/tools/git-sim#preflight |
|
Share
Copy linkCopy imageCopy embedDownload PNGDownload SVGDownload pageBluesky · LinkedIn · Reddit · Hacker News · Email
| https://www.programmergate.com/tools/git-sim#sharing |
| Share and embed custom Git simulations | https://www.programmergate.com/tools/git-sim#sharing |
|
Devlands: The First & Only Gamified Git Interface
| https://devlands.com |
|
git-sim: Visually simulate Git commands in your own repo
| https://github.com/initialcommit-com/git-sim |
|
My Talk @ GitHub's Git Merge 2025 Conference
| https://www.youtube.com/watch?v=6iEEQlGCjsE |
|
Coding books
| https://www.programmergate.com/store?type=book |
|
| https://www.programmergate.com/store/baby-bitcoin-guidebook-for-developers |
|
| https://www.programmergate.com/store/coding-essentials-guidebook-for-developers |
|
| https://www.programmergate.com/store/decoding-git-guidebook-for-developers |
|
Coding blog
| https://www.programmergate.com/blog |
|
Featured article
| https://www.programmergate.com/blog/git-sim-mistakes-and-fixes |
| Design mistakes I made in my open-source project git-sim in 2022 | https://www.programmergate.com/blog/git-sim-mistakes-and-fixes |
|
My Talk @ GitHub's Git Merge 2022 Conference
| https://www.youtube.com/watch?v=i6-z1kFPl0U |
|
Git's initial commit
| https://bitbucket.org/jacobstopak/baby-git/src/master/ |
|
| https://bitbucket.org/jacobstopak/baby-git/src/master/ |
|
30 day git crash course
| https://www.programmergate.com/store/30-day-git-crash-course |
|
| https://www.programmergate.com/store/30-day-git-crash-course |
|
Coding sessions
| https://www.programmergate.com/store/two-hour-coding-session |
|
| https://www.programmergate.com/store/two-hour-coding-session |
|
Ask a dev!
| https://www.programmergate.com/store/ask-a-dev |
|
Build your site!
| https://www.programmergate.com/store/initialcommit-cms |
|
| https://github.com/initialcommit-com |
|
| https://www.linkedin.com/in/jacob-stopak-6361b4b7 |
|
| https://www.instagram.com/initialcommit |
|
| https://www.facebook.com/initcommit |
|
| https://www.reddit.com/user/initcommit |
|
| https://twitter.com/initcommit |
| HOME | https://www.programmergate.com/ |
| EXPLORE | https://www.programmergate.com/learn/git/animated-cheat-sheet |
| Animated Git Cheat Sheet | https://www.programmergate.com/learn/git/animated-cheat-sheet |
| Visual Git command reference | https://www.programmergate.com/learn/git/visual-command-reference |
| Git command demos | https://www.programmergate.com/tools/git-sim/viewer#commands |
| LEARN | https://www.programmergate.com/learn/git |
| Git lessons | https://www.programmergate.com/learn/git |
| Git workflow demos | https://www.programmergate.com/tools/git-sim/viewer#workflows |
| Git commands | https://www.programmergate.com/learn/git/commands |
| Git articles | https://www.programmergate.com/learn/git/articles |
| Git basics | https://www.programmergate.com/learn/git/basics |
| Working with a team | https://www.programmergate.com/learn/git/team |
| Getting unstuck | https://www.programmergate.com/learn/git/rescue |
| All Git topics | https://www.programmergate.com/learn/git/topics |
| Python | https://www.programmergate.com/cluster/python |
| Java | https://www.programmergate.com/cluster/java |
| Amazon Web Services (AWS) | https://www.programmergate.com/cluster/amazon-web-services-aws |
| Spring Boot | https://www.programmergate.com/cluster/spring-boot |
| General Programming | https://www.programmergate.com/cluster/general-programming |
| History of Programming | https://www.programmergate.com/cluster/history-of-programming |
| JavaScript & Node.js | https://www.programmergate.com/cluster/javascript |
| Vim | https://www.programmergate.com/cluster/vim |
| DEVELOP | https://www.programmergate.com/tools |
| git-sim | https://www.programmergate.com/tools/git-sim |
| git-sim viewer | https://www.programmergate.com/tools/git-sim/viewer |
| git-sim live | https://www.programmergate.com/tools/git-sim#live |
| git-sim agentic | https://www.programmergate.com/tools/git-sim#agents |
| git-sim → VS Code | https://www.programmergate.com/tools/git-sim#vscode |
| git-dummy | https://www.programmergate.com/tools/git-dummy |
| Devlands | https://devlands.com |
| All tools | https://www.programmergate.com/tools |
| BOOKS | https://www.programmergate.com/store?type=book |
| BLOG | https://www.programmergate.com/blog |
| ABOUT | https://www.programmergate.com/about |
| CONTACT | https://www.programmergate.com/contact |
| Privacy Policy | https://www.programmergate.com/privacy-policy |