diff options
| author | Owen Jacobson <owen@grimoire.ca> | 2020-06-15 22:55:11 -0400 |
|---|---|---|
| committer | Owen Jacobson <owen@grimoire.ca> | 2020-06-15 22:55:11 -0400 |
| commit | 525eaccc129682741c55e5964abf3ed3f1896588 (patch) | |
| tree | 2dc998d1c33f705f33ab5e0c4f80666f12e8e9de | |
| parent | d98fc2cc48bde88700f85237ce0a19d52ad09605 (diff) | |
master -> main, but support repos that use master
| -rw-r--r-- | aliases.gitconfig | 8 | ||||
| -rwxr-xr-x | bin/git-start | 13 |
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 "$@" |
