Subject: Replacing a Remote Branch

From: Eric James Michael Ritz <[email-masked]>
Date: Fri, 23 Jul 2010 16:14:51 -0400

Hello everyone.  I have a question about pushing branches that I hope
a more experienced user could help me with.

Commonly I run into this situation:

  1. I have pushed a topic branch out to a repo where other developers
  on my team push their work until its ready to be merged.

  2. I realized I need to perform some ‘destructive’ action like
  ‘rebase -i’ or amend the last commit to fix a typo in the message.

  3. Then I want to push the changed branch as a replacement.

Currently I deal with this by running

    $ git push origin :foo && git push origin foo

to replace `foo`.  But is there a shorter way to do this?  I thought
that writing something like

    $ git push origin +foo:foo

may have the intended effect, but I still get a rejection due to a
non-fast-forward, so I am likely misunderstanding the purpose of `+`.

If there is any short-cut for this, I would greatly appreciate it.
And if not, writing a simple script is not a huge hassle :)

- --
Eric James Michael Ritz
Cyber Sprocket Labs
(843) 225-3830