简体   繁体   English

推后Git弄乱了我的文件

[英]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. 我认为所有文件都存在差异是有问题的,因为我的Windows计算机没有在末尾添加新行。 How do I resolve this? 我该如何解决?

Edit: I should mention that it did this to all 1000 (or so) files. 编辑:我应该提到它对所有1000个(或大约)文件执行了此操作。 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. 我不知道为什么,到目前为止,所有答案都只是告诉我手动编辑所有1000个文件,这不是一个合理的解决方案。 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 . 据我所知,当存在合并冲突之前, push不应真正提交您的更改,除非您解决了它们,所以您应该能够使用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 为了确保不再发生这种情况,请看以下页面: https : //help.github.com/articles/dealing-with-line-endings

Hope that helps! 希望有帮助!

This is the result of a conflicted merge . 这是merge冲突的结果。 Git alone couldn't merge the files, so leaved the differences in the file for you to edit. 仅Git无法合并文件,因此请保留文件中的差异供您编辑。 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. 删除其中一组代码(不需要的一组代码),就可以了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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