Skip to content

Instantly share code, notes, and snippets.

@tcelestino
Last active July 26, 2019 17:56
Show Gist options
  • Select an option

  • Save tcelestino/9790976 to your computer and use it in GitHub Desktop.

Select an option

Save tcelestino/9790976 to your computer and use it in GitHub Desktop.
git snippets

Git Snippets

BRANCH

git clone -b <branchName> <urlRepo> #faz o clone de um  branch especifico.
git branch -D <branchName> #deletar branch local
git push origin --delete <branchName> #atualiza repo com a remoção da branch
git branch -m <oldName> <newName> #renomeia uma branch
git push --set-upstream origin <branchName> #faz push da branch local para o repo
git branch --merged | grep -v \* | xargs git branch -D  #deleta todas as branches locais

COMMIT

git reflog #lista os commits com sua hash
git commit --amend -m "New commit message" #renomeia uma commit

TAG

git tag -d <tag> #remove uma tag
git push origin :refs/tags/<tag> #atualiza repo com a remoção da tag

OUTROS

git rm $(git ls-files --deleted) #remove todos os arquivos que foram deletados
git add -u #remove os arquivos que foram deletados
git reset --hard _commit_ #reseta a hash especificada após o --hard
git update-index --assume-unchanged nome_do_arquivo # reseta os arquivos trackeados
git clean -fd #limpa o stage
git gc prune=now #atualiza os remotos locais.
git reset HEAD^ # remove commit locally
git push origin +HEAD # force-push the new HEAD commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment