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
  • 20,799
  • 66
  • 75
  • 101
Liran
  • 307
  • 1
  • 4
  • 11

2 Answers2

4

Execute this:

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

This should do the trick

git push origin branch_name -f
crea1
  • 11,077
  • 3
  • 36
  • 46
  • 5
    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