Skip to content

Instantly share code, notes, and snippets.

@janschumann
Created February 12, 2014 19:35
Show Gist options
  • Save janschumann/8962917 to your computer and use it in GitHub Desktop.
Save janschumann/8962917 to your computer and use it in GitHub Desktop.
find out which remote branch is tracked by the current branch
#!/bin/sh -e
# find out which remote branch is tracked by the current branch
branch=$(git symbolic-ref HEAD)
branch=${branch##refs/heads/}
remote=$(git config "branch.${branch}.remote")
remoteBranch=$(git config "branch.${branch}.merge")
remoteBranch=${remoteBranch##refs/heads/}
echo "${remote:?}/${remoteBranch:?}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment