简体   繁体   English

git pull问题与未跟踪的文件

[英]git pull issue with untracked files

This is my scenario. 这是我的情况。

I realised I had a filename in the wrong case on my server. 我意识到我的服务器上的文件名有误。 So I changed the filename to the right case and it fixed the problem. 因此,我将文件名更改为正确的大小写,从而解决了该问题。

On my local machine, I renamed the file in Git and pushed the change. 在本地计算机上,我在Git中重命名了文件并推送了更改。

Back on my server, I have run git pull and now it's saying: 回到我的服务器上,我运行了git pull ,现在说:

The following untracked working tree files would be overwritten by merge 以下未跟踪的工作树文件将被合并覆盖

Please move or remove them before you can merge 请先移动或删除它们,然后再进行合并

And it lists the file I renamed. 它列出了我重命名的文件。 I can understand why it's doing this, but I am happy for it to overwrite the file. 我可以理解为什么这样做,但是我很高兴它能覆盖文件。

What do I need to run so I can finish my git pull ? 我需要运行什么才能完成git pull

Thanks 谢谢

What can I do so the git pull 我该怎么办git pull

To summate what happened: 总结发生了什么:

  1. You performed something like mv somename someName on the server (which is essentially another local repo) 您在服务器上执行了mv somename someName之类的操作(本质上是另一个本地存储库)

This caused git to see that somename was deleted and also found that someName was a new untracked file. 这导致git看到somename被删除,并且还发现someName是一个新的未跟踪文件。

  1. You performed git mv somename someName on your local repo 您在本地git mv somename someName上执行了git mv somename someName

Git correctly tracks this as a file rename and handles it appropriately. Git会正确地将此作为文件重命名进行跟踪并适当地处理它。 Other repos pulling this change would rename the file in question appropriately with no issues. 其他执行此更改的存储库将适当地重命名有问题的文件,没有问题。

  1. You did git commit and git push from your local repo to remote 你做了git commitgit push从本地仓库到远程
  2. You tried to git pull onto your server from the remote repo 您尝试将git pull从远程仓库git pull服务器上

This didn't work because in git's eyes, you could have made an entirely new someName file, which would get clobbered by the newest remote repo's version of someName if git wasn't awesome and prevented bad things from happening. 这是行不通的,因为在git的眼中,您可能制作了一个全新的someName文件,如果git效果不佳并且可以防止不良情况发生,则它将被someName的最新远程回购版本所someName

The proper steps to take action would have been: 采取行动的正确步骤应该是:

  1. Perform git mv somename someName on either of the local repos 在任一本地git mv somename someName上执行git mv somename someName
  2. git commit , git push on the same repo git commitgit push相同的仓库
  3. git pull on the other local repos git pull其他本地存储库

and the file renaming would have worked appropriately. 文件重命名就可以正常工作。

To remedy the issue you're having you can: 要解决此问题,您可以:

  1. Delete the untracked file (or mv someName somename to revert the file back to its former local glory) on your server's repo and simply do git pull 删除服务器存储库中的未跟踪文件(或mv someName somename将文件恢复为以前的本地荣耀),只需执行git pull
  2. git add someName , git commit -m "Fixing a conflict mistake" , git pull (to recursively merge the commit from the remote repo to your server repo's commit), and then git push git add someNamegit commit -m "Fixing a conflict mistake"git pull (将来自远程git add someName git commit -m "Fixing a conflict mistake"递归合并到服务器仓库的提交),然后进行git push
  3. Remove all of the untracked changes by following these instructions 按照以下说明删除所有未跟踪的更改

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

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