Registro de alterações

Git Cheat Sheet

Git common commands cheat sheet, quickly find and copy Git commands

Configuration and Initialization
9
git init

Initialize a new Git repository in the current directory

git init --bare

Initialize 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 --list

View all configurations

git config --global core.editor vim

Set default editor

Basic Operations
15
git status

View working directory status

git status -s

View concise status

git add <file>

Add file to staging area

git add .

Add all changes to staging area

git add -p

Interactive add, selectively stage changes

git commit -m "Commit message"

Commit staged changes

git commit --amend

Amend the last commit

git commit --amend --no-edit

Amend the last commit (without changing the commit message)

git commit -am "Commit message"

Add changes from all tracked files and commit

git diff

View differences between working directory and staging area

git diff --staged

View 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

Branch Management
13
git branch

List local branches

git branch -a

List all branches (including remote)

git branch -r

List 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 -vv

View detailed branch information (including upstream branch)

Remote Repositories
17
git remote -v

View 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 --all

Fetch updates from all remote repositories

git fetch -p

Fetch updates and prune deleted remote branches

git pull

Pull and merge remote branch

git pull --rebase

Pull and rebase

git push

Push to remote repository

git push -u origin <branch>

Push and set upstream branch

git push --force

Force push (use with caution)

git push --force-with-lease

Safe force push

git push --tags

Push all tags

git push origin --delete <branch>

Delete remote branch

Undo and Revert
12
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~1

Undo last commit, keep changes in staging area

git reset HEAD~1

Undo last commit, keep changes in working directory

git reset --hard HEAD~1

Undo 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 -fd

Delete untracked files and directories

git clean -nd

Preview untracked files to be deleted

Staging Operations
12
git stash

Stash current changes

git stash save "description message"

Stash and add description

git stash -u

Stash including untracked files

git stash list

View stash list

git stash pop

Restore the most recent stash and delete it

git stash apply

Restore the most recent stash but do not delete it

git stash apply stash@{n}

Restore a specific stash

git stash drop

Delete the most recent stash

git stash drop stash@{n}

Delete a specific stash

git stash clear

Clear all stashes

git stash show -p

View detailed stash content

git stash branch <branch>

Create a new branch from stash

View Logs
14
git log

View commit history

git log --oneline

Display commit history in one line

git log --oneline --graph

Display commit history graphically

git log --oneline --graph --all

Display 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 --stat

Show file change statistics for each commit

git log -p

Show detailed diff for each commit

git reflog

View all operation records (including deleted commits)

git show <commit>

View details of a specific commit

git shortlog -sn

Count commits by author

Tag Management
10
git tag

List 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 --tags

Push all tags

git push origin --delete <tagname>

Delete a remote tag

Merge and Rebase
10
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 --abort

Abort merge

git rebase <branch>

Rebase the current branch onto the specified branch

git rebase -i HEAD~n

Interactively rebase the last n commits

git rebase --continue

Continue rebase

git rebase --abort

Abort rebase

git cherry-pick <commit>

Apply the specified commit to the current branch

git cherry-pick -n <commit>

Apply commit without auto-committing

Advanced Operations
13
git bisect start

Start a binary search (locate problematic commit)

git bisect bad

Mark the current commit as bad

git bisect good <commit>

Mark the specified commit as good

git bisect reset

End 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 list

List all worktrees

git submodule add <url> <path>

Add a submodule

git submodule update --init --recursive

Initialize and update all submodules

git archive --format=zip HEAD > archive.zip

Package the repository as a zip file

git gc

Clean up and optimize the repository

git fsck

Check repository integrity

📖Introdução à ferramenta.

The Git Cheat Sheet is a quick reference tool for Git commands designed specifically for developers. It covers all common commands from basic operations to advanced techniques, organized by function, supporting quick search and one-click copy. Whether you are a Git beginner or an experienced developer, you can quickly find the commands you need here. All commands are accompanied by clear Chinese explanations to help you better understand and use Git.

Recursos.

1
10+ categories, covering all common Git scenarios
2
100+ common commands, comprehensively covering from basic to advanced
3
Supports keyword search to quickly locate desired commands
4
One-click copy command, improving work efficiency
5
Clear Chinese explanations, easy to understand and learn
6
Browse and filter by category to quickly find relevant commands
7
Responsive design, supports mobile viewing
8
Runs locally, usable without internet

Perguntas frequentes.

🔗Ferramentas relacionadas.

Analisador de expressões Cron

Valide a sintaxe Cron e pré-visualize os horários de execução futuros.

Ferramentas para desenvolvedores
Usar agora

JSON para CSV

Converter dados JSON para o formato CSV

Conversor
Usar agora

JSON para YAML

Converter dados JSON para o formato YAML

Conversor
Usar agora

Conversor de JSON para XML

Converter dados JSON para o formato XML

Conversor
Usar agora

YAML para JSON

Converter configuração YAML para dados no formato JSON

Conversor
Usar agora

Formatador de JSON

Formatar, validar e comprimir dados JSON

Ferramentas úteis de JSON
Usar agora

Visualização de JSON

Exibir dados JSON em estrutura de árvore

Ferramentas úteis de JSON
Usar agora

Gerador de dados JSON

Gerar dados JSON simulados para testes

Ferramentas úteis de JSON
Usar agora

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.

Ferramentas úteis de JSON
Usar agora

Comparação de diferenças de JSON

Comparar as diferenças entre dois JSONs.

Ferramentas úteis de JSON
Usar agora

Gerador de código QR

Gerar imagem de código QR personalizada

Ferramentas de imagem
Usar agora

Gerador de imagens placeholder SVG

Gerar imagem placeholder SVG personalizada

Ferramentas de imagem
Usar agora

Conversor de imagens Base64

Ferramenta de conversão entre imagens e codificação Base64

Ferramentas de imagem
Usar agora

Gerador de UUID

Gerar UUIDs únicos em lote

Ferramentas geradoras
Usar agora

Gerador de senhas

Gerar senhas aleatórias seguras e confiáveis

Ferramentas geradoras
Usar agora

Codificação e decodificação Base64

Ferramenta de codificação e decodificação de strings Base64

Ferramentas de texto
Usar agora

Codificação/decodificação de URL

Ferramenta de codificação e decodificação de strings URL

Ferramentas de texto
Usar agora

Gerador de hash MD5

Ferramenta para gerar hash MD5

Ferramentas de criptografia
Usar agora

Gerador de hash SHA256

Ferramenta para gerar hash SHA256

Ferramentas de criptografia
Usar agora

Gerador de hash SHA1

Ferramenta para gerar hash SHA1

Ferramentas de criptografia
Usar agora

Codificador/decodificador hexadecimal

Ferramenta de codificação/decodificação de strings hexadecimal

Ferramentas de criptografia
Usar agora

Codificador/decodificador binário

Ferramenta de codificação/decodificação de strings binárias

Ferramentas de criptografia
Usar agora

Criptografador/Descriptografador AES

Ferramenta de criptografia e descriptografia AES (algoritmo de criptografia simétrica)

Ferramentas de criptografia
Usar agora

Ferramenta de criptografia/descriptografia RSA

Ferramenta de criptografia RSA assimétrica

Ferramentas de criptografia
Usar agora

Gerador de HMAC

Gerador de código de autenticação de mensagem HMAC.

Ferramentas de criptografia
Usar agora

Consulta de endereço IP

Localização geográfica e informações de rede do endereço IP

Ferramentas de rede
Usar agora

Conversor de milissegundos

Converte entre carimbo de tempo em milissegundos e a string yyyy-MM-dd HH:mm:ss.

Ferramentas de tempo
Usar agora
Exibindo 27 ferramentas, total de 28 disponíveis
    Git Cheat Sheet - Quick Reference for Common Commands - IT Tools Collection