File: git-fresh-branch

package info (click to toggle)
git-extras 7.4.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 2,120 kB
  • sloc: sh: 4,312; python: 994; makefile: 146
file content (24 lines) | stat: -rwxr-xr-x 400 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/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