I've created a repository in the project's directory. I've added all the files and made some commits. Then I added new files to project and to repository. After that I returned to earlier version and now I can't update to last version. After hg update tip
I'm getting this message:
abort: untracked file in working directory differs from file in requested
revision: '.DS_Store'
I'm new to mercurial. How can I fix this?
It means that Mercurial is unsure about what to do. You have a file with content something
in the working copy. The file is not version controlled, so Mercurial will normally leave it alone when you update. However, the revision you're updating to also has a file with the same name, and the content differs from the something
you already have in the file.
You can get this problem if you do
$ hg init
$ echo "a file" > a
$ hg add a
$ hg commit -m "added a"
$ echo "b file" > b
$ hg add b
$ hg commit -m "added b"
You now have two revisions, the latest has files a
and b
. If you update back to the first revision and create a different file b
, then you get trouble:
$ hg update 0
$ echo "other b file" > b
$ hg update
abort: untracked file in working directory differs from file in requested
revision: 'b'
The normal solution is to commit before updating. You should generally not update with a dirty working copy ("dirty" means that hg status
isn't empty). Mercurial does support such updates, but you should only use them if you know what you're doing.
So to continue the example above we can either commit the new b
and then merge:
$ hg add b
$ hg commit -m "added new b"
$ hg merge
This gives a conflict in b
since the two versions contain b file
and other b file
, respectively. Resolve the conflict and commit:
$ hg commit -m "merged two bs"
An alternative is to delete the file from the working copy. That is what I'll do in your case: .DS_Store
files should not be tracked in the first place. They store some folder information on Mac OS X and this is not part of your source code. So you do
$ rm .DS_Store
$ hg update
The update resurrected the .DS_Store
file. You now want to tell Mercurial that it should stop tracking the file:
$ hg forget .DS_Store
and you also want to tell Mercurial to ignore such files from now on:
$ echo "syntax: glob" >> .hgignore
$ echo ".DS_Store" >> .hgignore
$ hg commit -m "removed .DS_Store file, ignored from now on"