diff --git a/git/gitconfig b/git/gitconfig index b28102d..245b565 100644 --- a/git/gitconfig +++ b/git/gitconfig @@ -33,15 +33,18 @@ bsync = "!source ~/.githelpers && update_branch" bp = !git backport backport = "!source ~/.githelpers && backport_pr" + track = "!source ~/.githelpers && track_remote" todo = grep --heading --break --ignore-case -e ' FIX: *' -e ' TODO: *' pr = "!source ~/.githelpers && get_pr" prd = "!source ~/.githelpers && del_pr" brc = "!source ~/.githelpers && clean_branches" + lbr = for-each-ref --sort='-committerdate:iso8601' --format=' %(committerdate:iso8601)%09%(refname)' refs/heads [merge] tool = vimdiff ff = true [push] default = current + followTags = true [branch] autosetuprebase = always diff --git a/git/githelpers b/git/githelpers index 5098858..44f33f8 100644 --- a/git/githelpers +++ b/git/githelpers @@ -124,3 +124,11 @@ backport_pr() { # switch back if we didn't start in the target branch [ "$THISBRANCH" != "$BRANCH" ] && git checkout - } + +track_remote() { + REMOTE=$1 + : ${REMOTE:="origin"} + BRANCH=$2 + [ -z "$BRANCH" ] && BRANCH=`git rev-parse --abbrev-ref HEAD` + git branch --set-upstream-to=${REMOTE}/${BRANCH} ${BRANCH} +} \ No newline at end of file