Instantly share code, notes, and snippets.

Embed
What would you like to do?
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