mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 15:36:21 -04:00
25 lines
408 B
Bash
Executable file
25 lines
408 B
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
branch=$1
|
|
|
|
test -z $branch && echo "branch required." 1>&2 && exit 1
|
|
|
|
changes=`git status --porcelain`
|
|
|
|
clean()
|
|
{
|
|
git symbolic-ref HEAD refs/heads/$branch
|
|
rm .git/index
|
|
git clean -fdx
|
|
}
|
|
|
|
if [ ! -z "$changes" ]; then
|
|
read -p "All untracked changes will be lost. Continue [y/N]? " res
|
|
case $res in
|
|
[Yy]* ) clean; break;;
|
|
* ) exit 0;;
|
|
esac
|
|
fi
|
|
|
|
clean
|