Created
March 16, 2010 10:17
-
-
Save washingtontimes/333816 to your computer and use it in GitHub Desktop.
A git command to push a local branch to the origin repository.
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/bash | |
function push_branch () { | |
HAS_REMOTE=`git show-ref remotes/origin/$1` | |
HAS_LOCAL=`git show-ref heads/$1` | |
if [[ $HAS_REMOTE ]]; then | |
echo "The remote repository already has a branch named $1" | |
exit | |
fi | |
if [[ $HAS_LOCAL == '' ]]; then | |
echo "There isn't a local branch named $1" | |
exit | |
fi | |
`git push origin $1` | |
`git config branch.$1.merge refs/heads/$1` | |
`git config branch.$1.remote origin` | |
} | |
push_branch $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment