Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/usr/local/bin/git-pushu (assumes that you always like your `origin` remote)
#!/bin/bash
if ( git status | grep "origin" -q ); then
git push $@
else
branch_name="$(git symbolic-ref HEAD 2>/dev/null)"
git push --set-upstream origin "${branch_name##refs/heads/}"
git push $@
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment