Skip to content

Instantly share code, notes, and snippets.

@nikolasrangel
Last active January 6, 2021 20:33
Show Gist options
  • Save nikolasrangel/ae84d504c7e8ebfa29f59dca2fe30150 to your computer and use it in GitHub Desktop.
Save nikolasrangel/ae84d504c7e8ebfa29f59dca2fe30150 to your computer and use it in GitHub Desktop.
a famosa colinha de comandos git
> log in line
git log --oneline
> retrive all commits by a message
git log --all --grep="corinthians"
> retrieve all commits by an author
git log --author="Nikolas"
> get everything you did
git reflog
> reset to the desired commit
git reset --hard commit-sha1
> reset the local repository to the remote main branch
git reset --hard origin/main
> get the differences between my branch and main brach
git diff main..my-spectacular-branch
> ammending without edit the message
git commit --amend --no-edit
> git stash
git stash pop
> git stash and keeping the state in stash
git stash apply
> stash with a message
git stash save "message"
> removing all branches that no longer exists in remote
git fetch -p
> git push
git push origin HEAD --force-with-lease
> pull and rebasing
git pull --rebase
> rebase
git rebase origin/main -i
git rebase HEAD~3 -i
> rename the current branch
git branch -m <new_name>
> undo the last commit and keeping the changes (to remove use --hard flag)
git reset HEAD~1
> delete a local branch (use -D flag to force a delete from a branch not fully merge)
git branch -d <branch_name>
> show the latest stable tag version
git describe --abbrev=0 --tags
> create a tag
git tag <tag_version>
> push a tag to origin
git push origin <tag_name>
> fetch remote tags
git fetch --tags
> delete a local tag
git tag -d <tag_name>
> delete a remote tag
git push --delete origin <tag_name>
> rebasing with a specific commit hash
git rebase -i commit_hash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment