user1449855 user1449855 - 1 year ago 160
Git Question

How can I make an older commit HEAD in Git?

I'm still trying to learn the (basic?) finer points of Git and have managed to get myself into trouble. I realized that I made some mistakes on HEAD, checked out an older commit and started coding from there. When I attempt a push I'm told that my current commit is behind and I need to merge with HEAD. Git recommends "git pull". However, HEAD has the code I want to ignore. How do I solve this problem? Thanks so much for the help.


-------- HEAD (bad) ---------------------- + (behind conflict, requires
\ / merge with HEAD, which is
\------- Current commit (good) ----/ bad and needs to be ignored)

Answer Source

If your repository isn't being used by other people, you can safely do git push -f to overwrite the remote branch.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download