-
-
Save kipras/7070714 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# From: http://graysky.org/2008/12/git-branch-auto-tracking/ | |
# | |
# git-track should be added to your path. | |
# Sets up auto-tracking of a remote branch with same base name. | |
# Can set up "git track" so it feels built-in: | |
# git config --global --add alias.track '!git-track' | |
# | |
# Update: changed the way current branch name is determined, see: | |
# http://git-blame.blogspot.com/2013/06/checking-current-branch-programatically.html | |
# Also made sure that when not on any branch (in detached head state) - that track would | |
# not do anything | |
if tracking=$(git symbolic-ref --short -q HEAD) | |
then | |
git config branch.$tracking.remote origin | |
git config branch.$tracking.merge refs/heads/$tracking | |
echo "tracking origin/$tracking" | |
else | |
echo not on any branch | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment