Useful Git Commands

Git force update of reference pointer on branch

git update-ref -m ""   
git branch -f   

Git Rebase

git rebase --onto     

Find where a branch forked off (closest common ancestor)

git log | grep -A5 -B5 "$(git merge-base --fork-point master)"
git log | grep -A5 -B5 "$(git merge-base --octopus --all master)"

Git one-way sync

git reset --hard HEAD
git pull -X theirs

Show current tag/branch in prompt:

PS1=${PS1/\\$ /'$(__git_ps1 "(%s)")\$ '}

List all tags on all branches in repo

git log --topo-order --decorate=full --tags --no-walk
git-describe  //Describe a commit by the most recent tag reachable from it
cat .git/HEAD

Remove file from entire git history:

git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch <path_to_file_to_remove>" -f HEAD
git push -f