0

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

Community
  • 1
  • 1
b85411
  • 9,420
  • 15
  • 65
  • 119
  • 1
    Assuming that the server files are not actively being worked on and you want to forcibly reset it to the latest master, [you do this](http://stackoverflow.com/a/8888015/1188035). What I imagine you did was make the changes locally on both environments, committed the one environment, and tried to pull onto the other. – sjagr Dec 05 '14 at 03:24
  • There's a few minor changes I wouldn't mind keeping (just a few things commented out on the production server) so I wouldn't like to do a hard reset unless it's essential. Ideally I'd just like to know how I can force the git pull to overwrite that one untracked file. Cheers – b85411 Dec 05 '14 at 03:26
  • Try `git checkout -- path/to/that/one/untracked/file` and then do a `git pull` – sjagr Dec 05 '14 at 03:27
  • It says it "did not match any file(s) known to git". – b85411 Dec 05 '14 at 03:29
  • Ah, because you didn't track the filename change in git on the server. Assuming the files are the exact same between your server and the already-committed local repo, try `git add path/to/that/one/untracked/file`, `git commit -m "Fixing conflict"`, `git pull`, then `git push` to get everything back in sync. I'd say delete the file and just do a simple `git pull` but I'm guessing you need it to be in place for uptime. – sjagr Dec 05 '14 at 03:35
  • No problem! I've added an answer with an explanation for you to accept if it's solved your problem. – sjagr Dec 05 '14 at 03:57

1 Answers1

0

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
Community
  • 1
  • 1
sjagr
  • 15,983
  • 5
  • 40
  • 67