【问题标题】:Committing only some files in Mercurial在 Mercurial 中只提交一些文件
【发布时间】:2009-12-28 10:28:42
【问题描述】:

很多时候我对存储库中的文件进行两次不同的更改,我希望将这些更改视为两次连续提交。

例如在仓库中

  • prog.c
  • prog.h
  • README.txt

在修复错误 prog.cprog.h 时,我修复了 README.txt 中的错字。现在我想用自己的提交消息将更改提交到prog.c,然后再将更改提交到README.txt

在 git 中,我可以通过索引轻松做到这一点

git add prog.c prog.h
git commit -m 'bug #1234'
git commit README.txt -m 'some typos fixed'

在 Mercurial 中最好的方法是什么?

澄清:我(在编辑之前)使用了一个玩具示例,其中每个变更集都跨越一个文件。但是我想要一个通用的答案,当每个变更集中有很多文件时我应该怎么做。

【问题讨论】:

标签: version-control mercurial


【解决方案1】:
hg commit -m "bug #1234" prog.c prog.h

然后

hg commit -m "some typos fixed" README.txt

【讨论】:

  • 如果错误 #1234 有多个文件怎么办?
  • hg commit -m "bug #1234" prog.c prog.h
  • 如果你想要除 README.txt 之外的所有文件:hg commit -m "bug #1234" -X README.txt
  • 所有参数列表:hg help -v commit
【解决方案2】:

为此我喜欢 crecord mercurial 扩展:它让我可以逐个文件(逐个块,逐行)控制我在此提交中究竟想要什么。

【讨论】:

  • 或者是随 mercurial 一起提供并在 Windows 上运行的原始记录扩展。
猜你喜欢
  • 1970-01-01
  • 2012-01-01
  • 2011-11-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-09-17
  • 2017-04-24
相关资源
最近更新 更多