Created
June 25, 2015 15:37
-
-
Save shoaibi/ba13c6ed1ecb2e45e8bb to your computer and use it in GitHub Desktop.
Update git repository's origin
This file contains hidden or 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 | |
| origBranch=$(git rev-parse --abbrev-ref HEAD) | |
| upstreamBranch="$origBranch" | |
| E_BADARGS=65 | |
| if [ $# -ne 2 -o $# -ne 1 ]; then | |
| echo "Usage: $0 {new_origin} [{upstreamBranch}]" | |
| exit $E_BADARGS | |
| elif [ "x$2" != "x" ]; then | |
| upstreamBranch="$2" | |
| fi | |
| git remote rename origin old | |
| git remote add origin $1 | |
| git remote -v | |
| # test and make sure the DreamHost origin works properly for fetch and push | |
| git remote rm old | |
| git branch --set-upstream-to=origin/"$upstreamBranch" "$origBranch" | |
| git commit -am "Updated origin to $1" | |
| git pull -u |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment