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?
Asked
Active
Viewed 805 times
2 Answers
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. Andorigin
may need to be replaced by the remote name, but probably you don't need to change it

pedrorijo91
- 7,635
- 9
- 44
- 82
-
This is considered dangerous: https://developer.atlassian.com/blog/2015/04/force-with-lease/ – Akshat Mahajan Dec 26 '16 at 20:46