添加新文件后如何更新到 Mercurial 的最新版本?
我已经在项目目录中创建了一个存储库。我已经添加了所有文件并进行了一些提交。然后我将新文件添加到项目和存储库中。之后我回到了早期版本,现在我无法更新到最新版本。在 hg update Tip
之后,我收到此消息:
abort: untracked file in working directory differs from file in requested
revision: '.DS_Store'
我是 Mercurial 的新手。我该如何解决这个问题?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这意味着 Mercurial 不确定要做什么。您的工作副本中有一个包含内容
something
的文件。该文件不受版本控制,因此 Mercurial 通常会在您更新时保留它。但是,您要更新的版本也有一个同名的文件,并且内容不同于您已有的内容
文件。如果您这样做,您可能会遇到此问题。
您现在有两个修订版本,最新的版本包含文件
a
和b
。如果您更新回第一个修订版本并创建不同的文件b
,那么您就会遇到麻烦:正常的解决方案是在更新之前提交。您通常不应使用脏工作副本进行更新(“脏”意味着
hg status
不为空)。 Mercurial 确实支持此类更新,但只有当您知道自己在做什么时才应该使用它们。因此,要继续上面的示例,我们可以提交新的
b
然后合并:这会在
b
中产生冲突,因为两个版本都包含b 文件
> 和其他 b 文件
,分别。解决冲突并提交:另一种方法是从工作副本中删除文件。 这就是我在您的情况下要做的:
.DS_Store
文件首先不应被跟踪。它们在 Mac OS X 上存储一些文件夹信息,这不是源代码的一部分。所以你更新了
.DS_Store
文件。您现在想要告诉 Mercurial 它应该停止跟踪该文件:并且您还想告诉 Mercurial 从现在开始忽略此类文件:
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 thesomething
you already have in the file.You can get this problem if you do
You now have two revisions, the latest has files
a
andb
. If you update back to the first revision and create a different fileb
, then you get trouble: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:This gives a conflict in
b
since the two versions containb file
andother b file
, respectively. Resolve the conflict and commit: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 doThe update resurrected the
.DS_Store
file. You now want to tell Mercurial that it should stop tracking the file:and you also want to tell Mercurial to ignore such files from now on: