From 525eaccc129682741c55e5964abf3ed3f1896588 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Mon, 15 Jun 2020 22:55:11 -0400 Subject: master -> main, but support repos that use master --- aliases.gitconfig | 8 ++------ bin/git-start | 13 +++++++++++++ 2 files changed, 15 insertions(+), 6 deletions(-) create mode 100755 bin/git-start 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 "$@" -- cgit v1.2.3