Last active
April 13, 2017 21:15
-
-
Save jozic/02aaf3f6c87c96da92ad6c3f78a0dac3 to your computer and use it in GitHub Desktop.
git remote
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
## gitr - returns verbose output for remotes | |
## gitr joe - adds remote joe as a fork of this repo | |
## gitr -joe - removes remote joe | |
gitr() { | |
if [[ $# == 1 ]]; then | |
local name=$1 | |
if [[ $name == -* ]]; then # starts with -, e.g. "-joe" | |
name=${name:1}; | |
echo "removing remote $name"; | |
git remote remove $name; | |
else | |
echo "adding remote $name"; | |
git remote add $name $(git remote -v | head -n 1 | awk '{print $2}' | sed "s/:.*\//:$name\//"); | |
git fetch $name; | |
fi; | |
else | |
git remote -v | |
fi; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment