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 locally
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, selectively stage 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 detailed branch information (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 branch
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 working directory (Git 2.23+)
git restore --staged <file>Unstage changes (Git 2.23+)
git checkout -- <file>Discard changes in working directory (old way)
git reset --soft HEAD~1Undo last commit, keep changes in staging area
git reset HEAD~1Undo last commit, keep changes in working directory
git reset --hard HEAD~1Undo last commit, discard all changes
git reset HEAD <file>Unstage specified file
git reset --hard <commit>Reset to specified commit
git revert <commit>Create a new commit to revert a specified commit
git revert -n <commit>Revert 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 stash content
git stash branch <branch>Create a new branch from stash
git logView commit history
git log --onelineDisplay commit history in one 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 without auto-committing
git bisect startStart a binary search (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 author of changes for a specific 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
📖Introdução à ferramenta.
Recursos.
❓Perguntas frequentes.
🔗Ferramentas relacionadas.
Analisador de expressões Cron
Valide a sintaxe Cron e pré-visualize os horários de execução futuros.
JSON para CSV
Converter dados JSON para o formato CSV
JSON para YAML
Converter dados JSON para o formato YAML
Conversor de JSON para XML
Converter dados JSON para o formato XML
YAML para JSON
Converter configuração YAML para dados no formato JSON
Formatador de JSON
Formatar, validar e comprimir dados JSON
Visualização de JSON
Exibir dados JSON em estrutura de árvore
Gerador de dados JSON
Gerar dados JSON simulados para testes
Tradutor JSON i18n
Traduzir todo o arquivo de idioma JSON de uma só vez. Cole o conteúdo base, escolha o idioma-alvo; a ferramenta usará chaves achatadas para chamar a API OpenRouter.
Comparação de diferenças de JSON
Comparar as diferenças entre dois JSONs.
Gerador de código QR
Gerar imagem de código QR personalizada
Gerador de imagens placeholder SVG
Gerar imagem placeholder SVG personalizada
Conversor de imagens Base64
Ferramenta de conversão entre imagens e codificação Base64
Gerador de UUID
Gerar UUIDs únicos em lote
Gerador de senhas
Gerar senhas aleatórias seguras e confiáveis
Codificação e decodificação Base64
Ferramenta de codificação e decodificação de strings Base64
Codificação/decodificação de URL
Ferramenta de codificação e decodificação de strings URL
Gerador de hash MD5
Ferramenta para gerar hash MD5
Gerador de hash SHA256
Ferramenta para gerar hash SHA256
Gerador de hash SHA1
Ferramenta para gerar hash SHA1
Codificador/decodificador hexadecimal
Ferramenta de codificação/decodificação de strings hexadecimal
Codificador/decodificador binário
Ferramenta de codificação/decodificação de strings binárias
Criptografador/Descriptografador AES
Ferramenta de criptografia e descriptografia AES (algoritmo de criptografia simétrica)
Ferramenta de criptografia/descriptografia RSA
Ferramenta de criptografia RSA assimétrica
Gerador de HMAC
Gerador de código de autenticação de mensagem HMAC.
Consulta de endereço IP
Localização geográfica e informações de rede do endereço IP
Conversor de milissegundos
Converte entre carimbo de tempo em milissegundos e a string yyyy-MM-dd HH:mm:ss.