简体   繁体   中英

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.

Back on my server, I have run git pull and now it's saying:

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 ?

Thanks

What can I do so the git pull

To summate what happened:

  1. You performed something like mv somename someName on the server (which is essentially another local repo)

This caused git to see that somename was deleted and also found that someName was a new untracked file.

  1. You performed git mv somename someName on your local repo

Git correctly tracks this as a file rename and handles it appropriately. 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
  2. You tried to git pull onto your server from the remote repo

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.

The proper steps to take action would have been:

  1. Perform git mv somename someName on either of the local repos
  2. git commit , git push on the same repo
  3. git pull on the other local repos

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
  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
  3. Remove all of the untracked changes by following these instructions

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