简体   繁体   中英

Git messed up my files after push

I'm sure this is my fault but after a push, all of the files at my destination repositories contain two copies of themselves. It looks like:

<<<<<<< HEAD

code goes here

======

same code again

/* End of file config.php */
/* Location: ./application/config/config.php */
>>>>>>> 6962176130afe295144f1f6a27146da27b604762

And this is every file on the site. Trying another push doesn't resolve the problem. I think there was a problem where all of my files had differences because my windows machine wasn't appending the new line at the end or something. How do I resolve this?

Edit: I should mention that it did this to all 1000 (or so) files. The majority of these files were not edited at all and were not part of my commit. It just did this to literally every file. I cannot think of why and all of the answers so far are just telling me to manually edit all 1000 files, which is not a reasonable solution. Doing another push didn't work either, nothing happens.

To my knowledge, push shouldn't actually commit your changes when there are merge conflicts until you've resolved them, so you should be able to undo those changes on the destination repo using git reset --hard .

To ensure that this doesn't happen again, take a look at this page: https://help.github.com/articles/dealing-with-line-endings

Hope that helps!

This is the result of a conflicted merge . Git alone couldn't merge the files, so leaved the differences in the file for you to edit. You should open your files in a editor and keep the parts you want in the

<<<<<<< HEAD

======

After the editing do the commit again.

It's just showing you a conflict. The top one is your head revision and below the ===== is most likely what you pushed. I am guessing you added the commented code or there is some other minor difference. Delete one of the sets of code (The one you don't want) and you are good.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM