Skip to content

Instantly share code, notes, and snippets.

@jozic
Last active April 13, 2017 21:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jozic/02aaf3f6c87c96da92ad6c3f78a0dac3 to your computer and use it in GitHub Desktop.
Save jozic/02aaf3f6c87c96da92ad6c3f78a0dac3 to your computer and use it in GitHub Desktop.
git remote
## 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