0

I made a commit. Then realized I forgot to add a file to it so I did git commit --amend -C HEAD. Then I pushed to the remote repo. The problem is that I forgot I also pushed the unamended commit to remote, so now there's a conflict. How can I fix this?

Johnny
  • 7,073
  • 9
  • 46
  • 72

2 Answers2

2

The answer by pedrorijo91 rewrites public history and it won't be allowed in some remote configurations (deny non fast forward). If other users have access to the pushed code, it is better to undo the amend with git reset --soft @{u} and create a new commit with the changes in the index

avmohan
  • 1,820
  • 3
  • 20
  • 39
1

use the --force flag when pushing:

git push --force origin master

Note: master may need to be replaced by your branch name. And origin may need to be replaced by the remote name, but probably you don't need to change it

pedrorijo91
  • 7,635
  • 9
  • 44
  • 82