mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
git-fresh-branch: Check for changes and prompt for input before nuking. (Issue: #142)
This commit is contained in:
parent
14ef2a88ef
commit
28df09b103
|
|
@ -4,6 +4,21 @@ branch=$1
|
|||
|
||||
test -z $branch && echo "branch required." 1>&2 && exit 1
|
||||
|
||||
git symbolic-ref HEAD refs/heads/$branch
|
||||
rm .git/index
|
||||
git clean -fdx
|
||||
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
|
||||
|
|
|
|||
Loading…
Reference in a new issue