Last active
January 17, 2018 19:09
-
-
Save halferty/6a4dd112d0252c3fe5f80bf341c9f5b6 to your computer and use it in GitHub Desktop.
Reset git directory to a known state - no questions asked (have a simpler version? are you sure? what if you're in the middle of a rebase and have untracked files?)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias nuke-nuke-branch="nnuke_branch" | |
alias nuke-branch="nuke_branch" | |
function nuke_branch() | |
{ | |
if [ $# -eq 1 ]; then | |
git clean -f -d | |
git rebase --abort | |
git branch -D tempbranch &> /dev/null | |
find . -name "post-checkout" | xargs rm -rf | |
git checkout -b tempbranch | |
git fetch upstream | |
git branch -D $1 | |
git checkout -b $1 --track upstream/$1 | |
git branch -D tempbranch | |
git reset --hard HEAD | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment