This page lists a collection of interesting git commands

Resources

Some good resources

Commands

Purpose Command Comment
git reset git reset --hard <commit-hash>
git push -f origin master
Reset to a specific commit-hash
git reset git update-ref -d HEAD Reset to inital commit
git reset git reset --hard <remote>/<branch> Reset to status from remote
git checkout git checkout fb
git rebase master
Check out the fb branch, and rebase from master
delete a local branch git branch -d BRANCH_NAME Reference
delete a remote branch git push --delete origin BRANCH_NAME Reference
delete all branches on remote that are already merged git branch --merged | egrep -v "(\^\*|master|dev)" | xargs git branch -d Reference
git tag git tag -a <tag> <commit> -m "<commit message>" How to tag an older commit in Git?
Example:
git tag -a v1.4.0 9c7dbe0 -m "Release v.1.4.0"
Change author of a commit git commit --amend --author="Author Name <[email protected]>" -

Oneliner Powershell

GET-DATE -Format o | Out-File .\README.md; git add .\README.md; git commit -m "Test"; git push

Remove credentials from git

https://stackoverflow.com/questions/15381198/remove-credentials-from-git

git config --global --unset credential.helper
git config --system --unset credential.helper
git config --global credential.helper manager