mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 15:36:21 -04:00
25 lines
400 B
Bash
Executable file
25 lines
400 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 [ -n "$changes" ]; then
|
|
read -rp "All untracked changes will be lost. Continue [y/N]? " res
|
|
case $res in
|
|
[Yy]* ) ;;
|
|
* ) exit 0;;
|
|
esac
|
|
fi
|
|
|
|
clean
|