$ git config --global user.name "Luiz Filipy"
$ git config --global user.email "[email protected]"
$ git config --list
$ git log --oneline
$ git checkout <id-do-commit>
$ git checkout master
Para voltar no ultimo commit (arquivo - serve tambem caso o arquivo tenha sido excluido acidentalmente)
$ git checkout <arquivo>
Para voltar no ultimo commit (todos os arquivos de uma só vez - serve tambem caso os arquivos tenham sido excluidos acidentalmente)
$ git reset --hard
$ git clean -f
$ git config --global alias.<alias-escolhido> <comando>
$ git config --global --unset alias.<alias-escolhido>
$ git remote -v
$ git branch
$ git branch <branch>
$ git checkout <branch>
$ git checkout -b <branch>
<branch> a branch precisa ser cria no servidor para poder então envia-la da máquina local para o servidor
$ git push --set-upstream origin <branch>
$ git push -u origin <branch>
$ git pull
Não é possivel apagar a branch ativa
$ git branch -d <branch>
$ git checkout -D <branch>
$ git push --delete origin <branch>
$ git branch -m <branch-alvo> <branch-novo-nome>
Irá renomear sua branch que está ativa
$ git branch -m <branch>
Para "renomear" no servidor é preciso apagar (antes disso verificar se a branch a ser apagada sofreu alterações) a branch com o nome antigo, criar a branch com o novo nome e enviar a branch com o novo nome para o servidor.
Irá trazer as mudanças da <branch> para a branch atual.
$ git merge <branch>
$ git tag -a <tag> -m "<mensagem>"
$ git tag
$ git push origin <tag>
$ git checkout <tag>
$ git tag -d <tag>
$ git push --delete origin <tag>
Para criar uma tag em um commit especifico use
git checkout
e depois crie a tag.
$ git tag -a <tag> -m "<mensagem>"
$ git tag -a <tag> <sha-commit>
$ git stash
$ git stash save "<mensagem>"
$ git stash list
git stash apply
sempre pega o stash mais recente
$ git stash apply
Pega o mais recente stash e o remove
$ git stash pop
Pega um stash especifico e o remove
$ git stash pop stash@{<numero-stash>}
$ git stash drop stash@{<numero-stash>}
<numero> Numero de commits a voltar. Por exemplo, fiz 2 commits errados entao será:
git reset --hard HEAD~2
. Os commits feitos serão perdidos!
$ git reset --hard HEAD~<numero>
$ git commit --amend