Mercurial ignores a file rename (changing case)

hg forget
hg remove untracked files
hg remove file from commit
hg remove file from repository
hg status
hg untrack
hg move
hg commit

I'm working with a project I inherited from a Windows guy. It's under Hg version control. It got some inconsistent filename convention which I'm trying to fix so I renamed a file named jquery.fullpage.js to jquery.fullPage.js (just uppercased "P") to adhere to the original author of that jQuery library.

However, Hg doesn't detect the lowercase-uppercase change as a rename or even as deleted/created file. As a result, I can't commit that change and push it live. It works locally but on the remote staging server where I pushed, it gives 404 errors. Apparently, the files on the remote weren't renamed to the uppercase P.

I know I can fix this by deleting the file, commit, restore the file and rename, commit again but that seems to be a crude way of fixing it.

How do I fix this?

This is a case folding problem. Try to rename the file through Mercurial: hg rename jquery.fullpage.js jquery.fullPage.js.

Handling files in Mercurial, It will then continue to track the changes you make to the file every time you commit, until you Consider the case where we use hg rename to rename a file. To have Mercurial permanently ignore such files, create a file named .hgignore in  Just find a nearby Linux or Unix box, clone the problem repository onto it, and use Mercurial's hg rename command to change the names of any offending files or directories so that they will no longer cause case folding conflicts.

If you're renaming a file you are good to go with hg rename as already said.

However (at least on Windows), if you're renaming a folder then you can't rename it directly. The common workaround is to use an intermediate:

hg rename Foo tmp
hg rename tmp foo

Another workaround is using intermediate delete. But this is discouraged because you would lose the file history.

Mixed up directory name case, This explains why it is not possible to change the case of a file on windows on a single commit (e.g. to rename A.txt into It would be great to have some way to tell mercurial to use a particular case ignoring the file system. It's rather more common to need to rename a file than to make a copy of it. The reason I discussed the hg copy command before talking about renaming files is that Mercurial treats a rename in essentially the same way as a copy. Therefore, knowing what Mercurial does when you copy a file tells you what to expect when you rename a file.

If you're on OS X and you're using HFS that is case-aware but not case-sensitive, then Hg (nor Git, as I found out) will pick up the change. I use Linux and my co-worker uses OS X and we had a similar problem with Git. Going through an intermediate rename is one workaround, or using an intermediate delete as you suggested.

I believe Jakub's suggestion of using hg itself to effect the rename will work, but I haven't tried it, since I don't have hg installed.

Mercurial: The Definitive Guide: The Definitive Guide, conflicts of file changes, merging, 38–42 file name case, 107–108 of file renames, 69 of revision tags, 112 shared name between file and directory, untracked, 62 untracked, ignoring, 106 dirstates, 50 additional contents of, 58 avoidance of  Unless names are given, new files are ignored if they match any of the patterns in.hgignore. As with add, these changes take effect at the next commit. Use the -s/--similarity option to detect renamed files. This option takes a percentage between 0 (disabled) and 100 (files must be identical) as its parameter.

Also there is hg rename --after oldFile newFile if the change is already in place.

TipsAndTricks, Fixing case collisions on Windows If you have accidentally added a file, the way to undo that (changing its Ignore files in local working copy only File renames, attribute changes and files added also suffer from this  You can fix this in a few ways. You can rename the file in a case-sensitive way and commit the change: git mv --cached name.txt NAME.TXT. Please take care and back up anything you don't understand. If you're renaming a directory, you'll do a two stage rename with a temp name. git mv foo foo2 git mv foo2 FOO git commit -m "changed case of dir"

Renaming a file using the command line, $ git commit -m "Rename file" # Commits the tracked changes and prepares them to be pushed to a remote repository. # To remove this commit and modify the file,​  Today we experienced a new way in which Mercurial can fail you. I'm not talking about performance, twisted workflows, etc. This time we're talking about Mercurial being unable to handle things that you can put into your repository in one platform on others. The TL;DR version is, don't rename directories by just changing the case of their name.

Git is case-sensitive and your filesystem may not be, You can fix this in a few ways. You can rename the file in a case-sensitive way and commit the change: git mv --cached name.txt NAME.TXT. Windows 10 now offers an optional case-sensitive file system, just like Linux and other UNIX-like operating systems. All Windows processes will handle case-sensitive files and folders properly if you enable this feature. In other words, they’ll see “file” and “File” as two separate files.

Renaming file with differences only in casing doesn't work (#830 , I would expect to rename my file, and then have a pending change. I've actually tried activating the case sensitivity support in Git, but it fails on windows quite  Solution is to have a temporary pristine repository to find all ignored files: hg clone source temp cd temp rm -rf .hg hg init. In temp/ we have now a tree of all files in the source/ repository but not being added to the newly created empty repository. hg status -i. will show now all files ignored by .hgignore but in the

  • This worked. I'm not very happy with this solution. Though I have read more about the case-folding problem and it seems to be a problem with case-insensitive filesystems.
  • I used mv but it still didn’t cause the system I ran pull -uv on to rename it. Oh, I’m trying to rename a folder/directory which is addressed by the other answer.
  • What about a regex solution? lets say I changed many extension files from distinct folders ( all images )
  • Do I need a commit between those two renames?
  • Indeed, I am on OSX. It doesn't detect the change. The remote staging server is on Linux so the staging server works alright.
  • This did not work for me. Mercurial complains that newFile does not exist (even though it clearly does)
  • Make sure you wrote full path case sensitive.