Mercurial - 如何从版本控制中删除文件?
所以我不小心将一个配置文件(每台机器都不同)包含到我们的 Mercurial 存储库中。
如何让 Mercurial 不将其包含在版本控制中?我不想删除该文件,因为我仍然想要它。我也不希望导致该文件在其他开发人员的工作目录中被删除。
我该如何在 TortoiseHG 中做到这一点?
So I accidentally included a config file (different for each machine) into our mercurial repositories.
How can I get Mercurial to not include it in version control? I don't want to delete the file since I still want it. And I don't want to cause the file to get deleted on other developer's working directories either.
And how do I do this in TortoiseHG?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
右键单击该文件->乌龟HG ->忘记文件。单击“忘记”。提交并同步。
编辑:
您还需要将路径添加到您的 .hgignore 以防止它再次添加。您可以在 HG Commit 对话框中右键单击该文件并选择忽略它。
Right click on the file -> TortoiseHG -> Forget Files. Click Forget. Commit and Sync.
Edit:
You'll also want to add the path to your .hgignore to keep it from getting added again. You can right click on the file in the HG Commit dialog and choose to ignore it.
以下是通过命令行执行此操作的手动方法:
hg rm path/to/config/file
.hgignore
中。hg stat
来仔细检查您所做的一切是否正确。 (它不应显示在修改/添加的文件列表中)。编辑:
hg忘记
是最好的方法。hgforgetpath/to/config/file
.hgignore
并将路径添加到配置文件。hg ci
保存您的更改。hg stat
以确保一切按计划进行。请参阅 nates 答案以了解如何操作 TortoiseHG。
Here's the manual way of doing it through the command line:
hg rm path/to/config/file
.hgignore
.hg stat
on your repository to double check you did everything right. (It shouldn't show up in the list of modified/added files).Edit:
hg forget
is the best way to do this.hg forget path/to/config/file
.hgignore
and add the path to the config file.hg ci
to save your changes.hg stat
to ensure everything worked according to plan.See nates answer for how to do it TortoiseHG.
hg remove
或hg remove -f
?我认为
hgforget
也会将其从分支中删除。在这两种情况下,文件都会保留在您的目录中。
hg remove
orhg remove -f
?I think
hg forget
also removes it from the branch.In both cases, files are retained in your directory.
对于那些使用 SourceTree 的人来说,当您右键单击文件时,有一个选项
停止跟踪
,它基本上与hg忘记
或< code>git rm --cache,从存储库中删除文件,但不从硬盘中删除文件。For those using SourceTree, there is an option
Stop Tracking
when you right click a file, it basically does the same thing ashg forget
orgit rm --cache
, removing the file from repo but not from hard disk.将其添加到您的忽略列表中。
请参阅 .hgignore 文件。
TortoiseHG 使您可以通过“编辑忽略过滤器”菜单选项访问此配置文件。
add it to your ignore list.
See the .hgignore file.
TortoiseHG gives you access to this config file via the "Edit Ignore Filter" menu option.