#Configuração inicial
| Comando | Descrição | |
|---|---|---|
git config --global user.name "[name]" | Definir nome de usuário | |
git config --global user.email "[email]" | Definir e-mail | |
git config --list | Listar todas as configurações | |
git init | Inicializar novo repositório | |
git clone [url] | Clonar repositório remoto |
#Comandos básicos
| Comando | Descrição | |
|---|---|---|
git status | Verificar status | |
git add [file] | Preparar arquivo | |
git add . | Preparar todas as alterações | |
git commit -m "[message]" | Criar commit | |
git commit -am "[message]" | Preparar e fazer commit | |
git push | Enviar para o remoto | |
git pull | Obter do remoto | |
git fetch | Obter sem mesclar |
#Branches
| Comando | Descrição | |
|---|---|---|
git branch | Listar branches | |
git branch [name] | Criar novo branch | |
git checkout [branch] | Trocar de branch | |
git checkout -b [name] | Criar e trocar | |
git switch [branch] | Trocar de branch (novo) | |
git switch -c [name] | Criar e trocar (novo) | |
git merge [branch] | Mesclar branch | |
git branch -d [name] | Excluir branch | |
git branch -D [name] | Excluir forçadamente |
#Histórico
| Comando | Descrição | |
|---|---|---|
git log | Histórico de commits | |
git log --oneline | Uma linha por commit | |
git log --graph | Mostrar gráfico | |
git log -p | Mostrar patches | |
git show [commit] | Mostrar detalhes do commit | |
git diff | Mostrar alterações | |
git diff --staged | Alterações preparadas | |
git blame [file] | Mostrar autor por linha |
#Desfazer
| Comando | Descrição | |
|---|---|---|
git restore [file] | Descartar alterações | |
git restore --staged [file] | Remover do staging | |
git reset HEAD~1 | Desfazer último commit (manter alterações) | |
git reset --hard HEAD~1 | Desfazer último commit (descartar) | |
git revert [commit] | Reverter commit (novo commit) | |
git clean -fd | Remover arquivos não rastreados |
#Stash
| Comando | Descrição | |
|---|---|---|
git stash | Guardar alterações temporariamente | |
git stash save "[message]" | Guardar com mensagem | |
git stash list | Listar stashes | |
git stash pop | Aplicar e remover stash | |
git stash apply | Aplicar stash (manter) | |
git stash drop | Remover stash | |
git stash clear | Limpar todos os stashes |
#Remoto
| Comando | Descrição | |
|---|---|---|
git remote -v | Listar remotos | |
git remote add [name] [url] | Adicionar remoto | |
git remote remove [name] | Remover remoto | |
git push -u origin [branch] | Definir upstream e enviar | |
git push origin --delete [branch] | Excluir branch remoto |
#Tags
| Comando | Descrição | |
|---|---|---|
git tag | Listar tags | |
git tag [name] | Criar tag | |
git tag -a [name] -m "[msg]" | Criar tag anotada | |
git push origin [tag] | Enviar tag | |
git push origin --tags | Enviar todas as tags |
#Avançado
| Comando | Descrição | |
|---|---|---|
git rebase [branch] | Rebase | |
git rebase -i HEAD~[n] | Rebase interativo | |
git cherry-pick [commit] | Cherry-pick de commit | |
git bisect start | Iniciar bisect | |
git reflog | Log de referências | |
git submodule add [url] | Adicionar submódulo |
#Perguntas frequentes (FAQ)
이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다.