Mercurial:重命名然后使用旧名称创建新文件
我正在使用 TortoiseHg。我有一个文件 A。我使用重命名工具将其重命名为 B。一切看起来都很好。现在我想创建一个名为 A 的新文件。当我创建一个具有该名称的文件并将其添加到存储库时,它会向我显示新文件与旧文件 A(现已重命名为 B)的差异。
我怎样才能将A重命名为B,并能够添加一个新的A,你知道,新的A,并且不会让Hg认为我正在修改旧的、现在不存在的A?
编辑:事实上,我最初所做的是正确的事情,我只是没有正确提交重命名。 (我已经提交了,但只提交了新重命名的文件,而不是现在不存在的旧文件。)
I'm using TortoiseHg. I have a file A. I used the rename tool to rename this to B. All seems well. Now I want to create a new file named A. When I create a file with that name and go to add it to the repo, it's showing me a diff of my new file with the old A (which is now renamed to B.)
How can I rename A to B and be able to add a new A which is, y'know, new, and not have Hg think I'm modifying the old, now-nonexistent A?
Edit: In fact what I originally did was the right thing, I just wasn't committing the rename properly. (I had committed, but only committed the newly-renamed file, and not the now-nonexistent old file.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
重命名后需要提交,然后创建同名的新文件。
You need to commit after the rename and then create the new file with same name.
假设您的存储库中有文件
a.txt
。要将其重命名为b.txt
并添加名为a.txt
的不同文件,请使用 TortoiseHg 2.x 执行以下操作:a.txt
。在上下文菜单中,单击TortoiseHg > 重命名文件。b.txt
。单击重命名。b.txt
和删除的a.txt
。输入提交描述,然后单击提交。关闭提交窗口。a.txt
的新文件。右键单击它。在上下文菜单中,单击TortoiseHg > 添加文件。a.txt
。单击添加。a.txt
。输入提交描述,然后单击提交。关闭提交窗口。现在,您有了一个不同的
a.txt
,具有新的历史记录,以及b.txt
,它记得它曾经被命名为a.txt
。PS 这与 Vaibhav Bajpai 在他的答案中发布的步骤完全相同。如果您在处理以
hg
命令表示的步骤时遇到问题,您可能会遇到困难。Suppose you the file
a.txt
in your repository. To rename it tob.txt
and add a different file nameda.txt
, using TortoiseHg 2.x, do the following:a.txt
. In the context menu, click TortoiseHg > Rename File.b.txt
into the Destination text box. Click Rename.b.txt
and removeda.txt
. Enter the commit description, and click Commit. Close the Commit window.a.txt
. Right-click it. In the context menu, click TortoiseHg > Add Files.a.txt
is checked. Click Add.a.txt
checked. Enter the commit description, and click Commit. Close the Commit window.Now you have a different
a.txt
, with a fresh history, andb.txt
which remembers it used to be nameda.txt
.P.S. This is exactly the same steps as Vaibhav Bajpai posted in his answer. You may have a hard time if you have problems dealing with steps expressed as
hg
commands.