aboutsummaryrefslogtreecommitdiffstats
path: root/git-branch-script
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2005-07-11 21:30:23 -0700
committerLinus Torvalds <torvalds@g5.osdl.org>2005-07-11 21:30:23 -0700
commit37f1a519f2ea0ce912ccd7c623aea992147c3900 (patch)
treefd17678d983e39cce1093e011c04ed9cf35dde21 /git-branch-script
parent91dcdfd3b5331d955cfb60edf8930f1b5c142905 (diff)
downloadgit-37f1a519f2ea0ce912ccd7c623aea992147c3900.tar.gz
Add "git branch" script
You can use it as git branch <branchname> [start-point] and it creates a new branch of name <branchname>. If a starting point is specified, that will be where the branch is created, otherwise it will be created at the current HEAD. The sequence git branch xyz abc git checkout xyz can also be written as git checkout -b xyz abc as per the previous commit.
Diffstat (limited to 'git-branch-script')
-rwxr-xr-xgit-branch-script11
1 files changed, 11 insertions, 0 deletions
diff --git a/git-branch-script b/git-branch-script
new file mode 100755
index 0000000000..ade0abf069
--- /dev/null
+++ b/git-branch-script
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+. git-sh-setup-script || die "Not a git archive"
+
+branchname="$1"
+rev=$(git-rev-parse --verify --default HEAD "$2"^0) || exit
+
+[ -z "$branchname" ] && die "git branch: I want a branch name"
+[ -e "$GIT_DIR/refs/heads/$branchname" ] && die "$branchname already exists"
+
+echo $rev > "$GIT_DIR/refs/heads/$branchname"