git stash
git
Uso
git stash [push] [-u] [-m "<message>"]Guarda as mudanças inacabadas e devolve a árvore limpa; arquivos sem rastreio ficam para trás a menos que use -u, e pop apaga a entrada enquanto apply a mantém.
Opções comuns
| Opção | Significado |
|---|---|
| -u | include untracked files, which are otherwise left behind |
| -a | include ignored files too |
| -k | keep the staging area as it is |
| -p | stash selected hunks |
| pop | apply the newest entry and delete it |
| apply | apply it and keep the entry |
| list | show the entries |
| drop <stash> | delete one entry |
Exemplos
git stash -u -m "wip login"parks tracked and untracked changes under a name
git stash popbrings the newest stash back and removes it from the list
git stash apply stash@{2}applies an older entry and leaves it in the list
O confuso é que desfazer tem várias formas: mover para onde um branch aponta não é o mesmo que criar um commit que reverte.
Como ler
- Os colchetes [ ] marcam uma parte que você pode omitir.
- As reticências … indicam que você pode listar vários.
- As opções diferenciam maiúsculas: em alguns comandos -r e -R fazem coisas diferentes.
Perguntas
Q. O que git stash faz?
Guarda as mudanças inacabadas e devolve a árvore limpa; arquivos sem rastreio ficam para trás a menos que use -u, e pop apaga a entrada enquanto apply a mantém.
Q. Como se digita?
git stash [push] [-u] [-m "<message>"] — os colchetes marcam o que você pode omitir.
Q. Quantas opções vale a pena saber?
Aqui estão 8; a lista completa está em man git. Este comando fica em git.
Comandos relacionados
página man: man git-stash