summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--aliases.gitconfig8
-rwxr-xr-xbin/git-start13
2 files changed, 15 insertions, 6 deletions
diff --git a/aliases.gitconfig b/aliases.gitconfig
index 50cc24f..2eaf42e 100644
--- a/aliases.gitconfig
+++ b/aliases.gitconfig
@@ -29,10 +29,6 @@
prstash = config --add remote.origin.fetch +refs/pull-requests/*/from:refs/pull/*
## Branch lifecycle
- # Create a branch: `git start BRANCHNAME` (protip: run `git fall`
- # first.) The new branch will track origin/master by default.
- # Tracking info gets used below.
- start = checkout --track origin/master -b
# Branch log for the current branch: `git blog [log options]`
blog = log HEAD@{upstream}..HEAD
# Branch one-line summary (equivalent to `git blog --oneline`)
@@ -41,8 +37,8 @@
bdiff = diff HEAD@{upstream}...HEAD
# Upload a branch to personal fork: `git publish` - note that this
# will unconditionally overwrite the branch if it already exists,
- # potentially "losing" changes. Don't `git publish` master. Because of
- # limitations in git's aliases mechanism, this DOES NOT support `git
+ # potentially "losing" changes. Don't `git publish` main or master. Because
+ # of limitations in git's aliases mechanism, this DOES NOT support `git
# publish BRANCHNAME` the way you'd expect.
publish = !git push "${USER}" +HEAD
# "Accept" a branch by merging it: `git accept BRANCHNAME` - this
diff --git a/bin/git-start b/bin/git-start
new file mode 100755
index 0000000..8251fa4
--- /dev/null
+++ b/bin/git-start
@@ -0,0 +1,13 @@
+#!/bin/bash -e
+
+# Create a branch: `git start BRANCHNAME` (protip: run `git fall` first.) The
+# new branch will track origin/main by default, or origin/master if origin/main
+# doesn't exist. Tracking info gets used below.
+
+if git rev-parse --quiet --verify origin/main > /dev/null; then
+ exec git checkout --track origin/main -b "$@"
+elif git rev-parse --quiet --verify origin/master > /dev/null; then
+ exec git checkout --track origin/master -b "$@"
+fi
+
+exec git checkout --track origin/main -b "$@"