4

I have been working on a (remote) feature branch and after changing the branch history, I want to push it to Gerrit (with force push).

I tried the following command:

git push origin HEAD:refs/for/branch_name --force

However, instead of changing the branch history, it just pushed the changes on top of the branch.

What am I doing wrong? How can i force-push or change the remote branch history? thanks.

TylerH
  • 19,065
  • 49
  • 65
  • 86
Liran
  • 167
  • 3
  • 11

2 Answers2

3

Execute this:

git push -f origin HEAD:refs/heads/branch_name
1

This should do the trick

git push origin branch_name -f
crea1
  • 7,749
  • 3
  • 32
  • 39
  • 4
    This answer would've been a lot better if it explained why the OP's command produced the incorrect result and why this command worked better. – Magnus Bäck Jun 30 '15 at 05:50