Skip to content

Instantly share code, notes, and snippets.

@Wolfsblvt
Created May 1, 2015 13:18
Show Gist options
  • Save Wolfsblvt/74f4ddba00c03b59eb63 to your computer and use it in GitHub Desktop.
Save Wolfsblvt/74f4ddba00c03b59eb63 to your computer and use it in GitHub Desktop.
Function to make upstream to "upstream"
setupstream = "!f() { \
local rem=$(git remote | grep -v '^origin$') \
if [ \"$(wc -l <<<\"$rem\")\" -gt 1 ]; then \
echo 'Too many remotes.' >&2 \
return \
fi \
if [ -z \"$rem\" ]; then \
echo 'No non-origin remote found.' >&2 \
return \
fi \
if [ \"$rem\" = upstream ]; then \
echo '\"upstream\" remote already exists.' \
return \
fi \
git remote rename \"$rem\" upstream \
}; \
f"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment