Hacker News new | ask | show | jobs
by nicwolff 3283 days ago
This Bash function rebases and pushes all my feature branches on the upstream "develop" branch:

  rebase-all () 
  { 
      old=`git rev-parse --abbrev-ref HEAD`;
      stashed=`git stash`;
      for b in $(git branch --format '%(authorname) %(refname:short)' | sed -ne "s/^`git config --get user.name` //p" | grep -- -);
      do
          git checkout $b && git rebase origin/develop && git push --force || ( git rebase --abort && echo Could not rebase $b );
          echo;
      done;
      git checkout $old;
      if [ "$stashed" != "No local changes to save" ]; then
          git stash pop;
      fi
  }