CheatSheets

Git Cheat Sheet

CommandDescription
git initInitialize a new Git repository
git clone <repo>Clone an existing repository
git add <file>Add a file to the staging area
git commit -m "<message>"Commit changes with a message
git branch <name>Create a new branch
git checkout <branch>Switch to a different branch
git merge <branch>Merge a branch into the current branch
git pullPull changes from a remote repository
git pushPush local commits to a remote repository
git statusView the current status of the repository
git logView the commit history
git reset <file>Unstage a file
git diffView differences between committed versions
git stashStash changes to temporarily shelve them
git revert <commit>Revert to a previous commit
git tag <tagname>Create a tag to mark a specific commit
git fetchFetch changes from a remote repository without merging them
git blame <file>View the commit history for a file
git cherry-pick <commit>Apply changes from a specific commit
git clean -fRemove untracked files from the repository
git rebase <branch>Rebase the current branch onto another branch
git submodule <repo>Add a submodule to the repository
git cherry-pick <commit>Apply changes from a specific commit
git clean -fRemove untracked files from the repository
git submodule <repo>Add a submodule to the repository
git branch -D <branch>Delete a branch
git branch -m <newname>Rename a branch
git push <remote> --delete <branch>Delete a remote branch
git push <remote> <branch>Push a local branch to a remote repository
git branch -aList all local and remote branches
git checkout -b <branch>Create and switch to a new branch
git stash listView a list of stashes
git stash applyApply the latest stash
git stash popApply the latest stash and remove it from the stash list
git stash dropRemove the latest stash from the stash list
git stash clearRemove all stashes from the stash list
git tag -d <tagname>Delete a tag
git push <remote> :<branch>Delete a remote branch
git push <remote> --tagsPush all tags to a remote repository
git tag -v <tagname>Verify a tag's GPG signature
git remote -vList all remote repositories
git remote add <name> <url>Add a remote repository
git remote rename <oldname> <newname>Rename a remote repository
git remote remove <name>Remove a remote repository
git remote set-url <name> <newurl>Set the URL for a remote repository
git submodule initInitialize submodules in the repository
git submodule updateUpdate submodules to the latest commit
git submodule syncSynchronize submodule URLs with the parent repository
git submodule statusView the status of submodules in the repository
git submodule deinit <repo>Remove a submodule from the repository
git submodule foreach <command>Run a command in each submodule
git submodule summaryView a summary of changes in submodules
git config --global user.name "<name>"Set the user's name for Git commits
git config --global user.email "<email>"Set the user's email for Git commits
git config --global --listView the user's Git configuration
git config --global color.ui autoEnable color output for Git
git config --global core.editor "<editor>"Set the default text editor for Git
git config --global alias.<alias> "<command>"Set an alias for a Git command
git config --global --unset <key>Unset a Git configuration value
git config --global --replace-all <key> "<value>"Replace all instances of a Git configuration value
git config --global credential.helper "<helper>"Set a credential helper for Git
git config --global push.default simpleSet the default push behavior for Git
git config --global merge.conflictstyle diff3Set the default merge conflict style for Git
Previous
Closures