From 24e826f776331f717495ff3f6ea056e41b9d2200 Mon Sep 17 00:00:00 2001 From: Ivan Zakharyaschev Date: Fri, 24 Apr 2009 05:22:36 +0400 Subject: [PATCH] Added "git track-same" to quickly setup a simple default for pull. Useful for a repository which initially was the first source of a project, but which wants to sync with a central remote repo afterwards. --- git-track-same | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 git-track-same diff --git a/git-track-same b/git-track-same new file mode 100755 index 0000000..da2700e --- /dev/null +++ b/git-track-same @@ -0,0 +1,36 @@ +#!/bin/bash + +usage() { + printf $"Usage: %s\n" "git track-same [[REMOTE]#[BRANCH]]" + echo $"REMOTE defaults to 'origin'; BRANCH is the one pointed to by HEAD." + printf $"Example: $s" \ + 'git show-ref --heads | while read sha b; do git track-same "#$b"; done' +} + +case "$1" in + -*) + usage + exit 0 + ;; +esac + +set -e + +REMOTE="${1%\#*}" +if ! [[ "$REMOTE" ]]; then + REMOTE=origin +fi + +case "$1" in + *#*) BRANCH="${1##*#}" + ;; +esac +if ! [[ "$BRANCH" ]]; then + BRANCH="$(git symbolic-ref HEAD)" +fi + +readonly BRANCHNAME="${BRANCH##refs/heads/}" + +git config branch."$BRANCHNAME".remote "$REMOTE" \ + && git config branch."$BRANCHNAME".merge "$BRANCH" \ + && echo $"Options set." \ No newline at end of file -- 2.11.4.GIT