Skip to content

Instantly share code, notes, and snippets.

@nikreiman
Created February 15, 2012 10:01
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikreiman/1834857 to your computer and use it in GitHub Desktop.
Save nikreiman/1834857 to your computer and use it in GitHub Desktop.
Rebase all unpushed commits -- very nice to do before pushing
#!/bin/bash
function git-branch-current() {
printf "%s\n" $(git branch 2> /dev/null | grep -e ^* | tr -d "\* ")
}
function git-log-last-pushed-hash() {
local currentBranch=$(git-branch-current);
git log --format="%h" -n 1 origin/${currentBranch}
}
function git-rebase-unpushed() {
git rebase --interactive $(git-log-last-pushed-hash)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment