Git Cheat Sheet
Git Common Commands Cheat Sheet, quickly find and copy Git commands
git initInitialize a new Git repository in the current directory
git init --bareInitialize a bare repository (no working directory, for servers)
git clone <url>Clone a remote repository to local
git clone --depth 1 <url>Shallow clone, only fetch the latest commit (saves time and space)
git clone -b <branch> <url>Clone a specific branch
git config --global user.name "Name"Set global username
git config --global user.email "Email"Set global email
git config --listView all configurations
git config --global core.editor vimSet default editor
git statusView working directory status
git status -sView concise status
git add <file>Add file to staging area
git add .Add all changes to staging area
git add -pInteractive add, allows selecting parts of changes
git commit -m "Commit message"Commit staged changes
git commit --amendAmend the last commit
git commit --amend --no-editAmend the last commit (without changing the commit message)
git commit -am "Commit message"Add changes from all tracked files and commit
git diffView differences between working directory and staging area
git diff --stagedView differences between staging area and last commit
git diff <commit1> <commit2>Compare differences between two commits
git rm <file>Delete file and record the deletion
git rm --cached <file>Remove file from staging area, but keep it in the working directory
git mv <old> <new>Move or rename file
git branchList local branches
git branch -aList all branches (including remote)
git branch -rList remote branches
git branch <branch>Create a new branch
git checkout <branch>Switch to the specified branch
git checkout -b <branch>Create and switch to a new branch
git switch <branch>Switch branch (Git 2.23+)
git switch -c <branch>Create and switch branch (Git 2.23+)
git branch -d <branch>Delete a merged branch
git branch -D <branch>Force delete branch
git branch -m <old> <new>Rename branch
git branch -u origin/<branch>Set upstream branch for the current branch
git branch -vvView branch details (including upstream branch)
git remote -vView list of remote repositories
git remote add <name> <url>Add a remote repository
git remote remove <name>Remove a remote repository
git remote rename <old> <new>Rename a remote repository
git remote show <name>View remote repository details
git remote set-url <name> <url>Modify remote repository URL
git fetch <remote>Fetch updates from remote repository
git fetch --allFetch updates from all remote repositories
git fetch -pFetch updates and prune deleted remote branches
git pullPull and merge remote branches
git pull --rebasePull and rebase
git pushPush to remote repository
git push -u origin <branch>Push and set upstream branch
git push --forceForce push (use with caution)
git push --force-with-leaseSafe force push
git push --tagsPush all tags
git push origin --delete <branch>Delete remote branch
git restore <file>Discard changes in the working directory (Git 2.23+)
git restore --staged <file>Unstage (Git 2.23+)
git checkout -- <file>Discard changes in the working directory (old way)
git reset --soft HEAD~1Undo the last commit, keeping changes in the staging area
git reset HEAD~1Undo the last commit, keeping changes in the working directory
git reset --hard HEAD~1Undo the last commit, discarding all changes
git reset HEAD <file>Unstage specified file
git reset --hard <commit>Reset to a specific commit
git revert <commit>Create a new commit to undo a specific commit
git revert -n <commit>Undo commit without auto-committing
git clean -fdDelete untracked files and directories
git clean -ndPreview untracked files to be deleted
git stashStash current changes
git stash save "description message"Stash and add description
git stash -uStash including untracked files
git stash listView stash list
git stash popRestore the most recent stash and delete it
git stash applyRestore the most recent stash but do not delete it
git stash apply stash@{n}Restore a specific stash
git stash dropDelete the most recent stash
git stash drop stash@{n}Delete a specific stash
git stash clearClear all stashes
git stash show -pView detailed contents of a stash
git stash branch <branch>Create a new branch from a stash
git logView commit history
git log --onelineDisplay commit history in a single line
git log --oneline --graphDisplay commit history graphically
git log --oneline --graph --allDisplay commit history of all branches
git log -n <number>Display the last n commits
git log --author="name"Filter commits by author
git log --since="2024-01-01"Filter commits by date
git log --grep="keyword"Search by commit message
git log -- <file>View commit history of a specific file
git log --statShow file change statistics for each commit
git log -pShow detailed diff for each commit
git reflogView all operation records (including deleted commits)
git show <commit>View details of a specific commit
git shortlog -snCount commits by author
git tagList all tags
git tag -l "v1.*"List tags by pattern
git tag <tagname>Create a lightweight tag
git tag -a <tagname> -m "Description"Create an annotated tag
git tag <tagname> <commit>Create a tag for a specific commit
git show <tagname>View tag details
git tag -d <tagname>Delete a local tag
git push origin <tagname>Push a single tag
git push origin --tagsPush all tags
git push origin --delete <tagname>Delete a remote tag
git merge <branch>Merge the specified branch into the current branch
git merge --no-ff <branch>Non-fast-forward merge, preserve branch history
git merge --squash <branch>Squash merge, combine all commits into one
git merge --abortAbort merge
git rebase <branch>Rebase the current branch onto the specified branch
git rebase -i HEAD~nInteractively rebase the last n commits
git rebase --continueContinue rebase
git rebase --abortAbort rebase
git cherry-pick <commit>Apply the specified commit to the current branch
git cherry-pick -n <commit>Apply commit but do not auto-commit
git bisect startStart a binary search (to locate problematic commit)
git bisect badMark the current commit as bad
git bisect good <commit>Mark the specified commit as good
git bisect resetEnd binary search
git blame <file>View the last modifier of each line in a file
git blame -L 10,20 <file>View the modifier of a specified line range
git worktree add <path> <branch>Create a new worktree
git worktree listList all worktrees
git submodule add <url> <path>Add a submodule
git submodule update --init --recursiveInitialize and update all submodules
git archive --format=zip HEAD > archive.zipPackage the repository as a zip file
git gcClean up and optimize the repository
git fsckCheck repository integrity
πTool Introduction
Key Features
βFrequently Asked Questions
πRelated Tools
Cron Expression Parser
Validate cron syntax and preview upcoming schedules.
JSON to CSV
Convert JSON data to CSV format
JSON to YAML
Convert JSON data to YAML format
JSON to XML
Convert JSON data to XML format
YAML to JSON
Convert YAML configuration to JSON data
JSON Formatter
Format, validate and minify JSON data
JSON Visualizer
Display JSON data in tree structure
JSON Data Generator
Generate mock JSON data for testing
i18n JSON Translator
Translate entire JSON locale files in one go. Paste your base content, choose target languages, and the tool will call your OpenRouter-powered API with flattened keys.
JSON Diff Comparison
Compare differences between two JSON data
QR Code Generator
Generate custom QR code images
SVG Placeholder Generator
Generate custom SVG placeholder images
Base64 Image Converter
Convert images to Base64 encoding and vice versa
UUID Generator
Generate UUID unique identifiers in batch
Password Generator
Generate secure and reliable random passwords
Base64 Encoder/Decoder
Base64 string encoding and decoding tool
URL Encoder/Decoder
URL string encoding and decoding tool
MD5 Hash Generator
Generate MD5 hash values from text
SHA256 Hash Generator
Generate SHA256 hash values from text
SHA1 Hash Generator
Generate SHA1 hash values from text
Hex Encoder/Decoder
Hexadecimal string encoding and decoding tool
Binary Encoder/Decoder
Binary string encoding and decoding tool
AES Encrypt/Decrypt
AES symmetric encryption algorithm tool
RSA Encrypt/Decrypt
RSA asymmetric encryption algorithm tool
HMAC Generator
HMAC message authentication code generation tool
IP Address Lookup
Query geographical location and network information of IP addresses
Milliseconds Time Converter
Convert between millisecond timestamps and formatted date strings.