Created
November 25, 2008 20:19
-
-
Save sstephenson/29070 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 | |
branch=$(git branch 2>/dev/null | grep ^\*) | |
[ x$1 != x ] && tracking=$1 || tracking=${branch/* /} | |
git config branch.$tracking.remote origin | |
git config branch.$tracking.merge refs/heads/$tracking | |
echo "tracking origin/$tracking" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi!
I got the problems on the colored shell, that's why made some modifications to your script:
!/bin/sh
If argument is provided
if [ banana$1 != banana ]; then
tracking=$1
Get it from current branch
else
branch=$(git branch 2>/dev/null | grep ^* | awk '{print $2}')
echo "Current branch: "$branch
tracking=$branch
fi
git config branch.$tracking.remote origin
git config branch.$tracking.merge refs/heads/$tracking
echo "tracking origin/$tracking"