mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 15:36:21 -04:00
'break' isn't valid in its current location in the script, resulting in an error like: /usr/bin/git-fresh-branch: line 42: break: only meaningful in a `for', `while', or `until' loop Since there's a call to 'clean' right at the end of the script, do nothing if anything beginning 'Y' or 'y' is entered; execution will continue to the end of the script, and 'clean' will be called.
25 lines
396 B
Bash
Executable file
25 lines
396 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]* ) ;;
|
|
* ) exit 0;;
|
|
esac
|
|
fi
|
|
|
|
clean
|