Skip to content

Instantly share code, notes, and snippets.

@marcust
Created December 15, 2011 09:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcust/1480427 to your computer and use it in GitHub Desktop.
Save marcust/1480427 to your computer and use it in GitHub Desktop.
git-tracking - show information about what the current branch is tracking
#!/bin/sh
CURRENT_BRANCH=$(git name-rev --name-only HEAD)
REMOTE_REF=$(git config --get-regexp branch.$CURRENT_BRANCH.merge | cut -d' ' -f 2 | sed -e 's|refs/heads/||');
REMOTE=$(git config --get-regexp branch.$CURRENT_BRANCH.remote | cut -d' ' -f 2);
if [ -z "$1" -o "$1" = 'branch' ]; then
echo $REMOTE_REF
fi;
if [ "$1" = 'remote' ]; then
echo $REMOTE
fi;
if [ "$1" = 'full' ]; then
echo $REMOTE/$REMOTE_REF
fi;
if [ "$1" = 'name' ]; then
echo $REMOTE:$REMOTE_REF
fi;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment