Skip to content

Commit

Permalink
Adding git-tracks tool for finding upstream branch.
Browse files Browse the repository at this point in the history
  • Loading branch information
jlebar committed Jun 21, 2012
1 parent 0610126 commit d01ebb0
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions git-tracks
@@ -0,0 +1,15 @@
#!/bin/bash
#
# Based on http://serverfault.com/a/352236/38694

branch=$(git symbolic-ref HEAD) || exit $?
branch=${branch##refs/heads/}
remote=$(git config "branch.${branch}.remote") || exit $?
remoteBranch=$(git config "branch.${branch}.merge") || exit $?
remoteBranch=${remoteBranch##refs/heads/}

if [[ "$remote" != "." ]]; then
echo "${remote:?}/${remoteBranch:?}"
else
echo "${remoteBranch:?}"
fi

0 comments on commit d01ebb0

Please sign in to comment.