Skip to content

Instantly share code, notes, and snippets.

@ramonsnir
Created July 16, 2016 10:10
Show Gist options
  • Save ramonsnir/9ecd4624fe29218257c78b0308f6a5aa to your computer and use it in GitHub Desktop.
Save ramonsnir/9ecd4624fe29218257c78b0308f6a5aa to your computer and use it in GitHub Desktop.
/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