1

I need to change a file that i have already pushed but i don't want to do a new commit, so i tried amend. But when I try to push the changes to the remote branch it gives me an error. Do I need to do a force push or something else ?? I'm the only one working on this project so no one is going to pull this branch(I can use amend).

Thanks.

lads
  • 1,125
  • 3
  • 15
  • 29

2 Answers2

3

Yes, you will need to force push, which is fine if your are the only one working on the remote repository.

jil
  • 2,601
  • 12
  • 14
2

Yes, you can use force push, but please note that it should be allowed in your branch configuration.

git push origin [branch] -f

This will basically override the branch. So use it for shared remote branches like master with caution.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Karving
  • 56
  • 5
  • How would i do it if I need to push from a local branch A to a remote branch B git push origin A:B -f ? – lads Mar 31 '16 at 21:15
  • I have never tried to make git push when branch names different. But you are probably right: git push -f A:B – Karving Mar 31 '16 at 21:32