Version control 在两个分支之间创建更改提交

Version control 在两个分支之间创建更改提交,version-control,merge,mercurial,branching-and-merging,Version Control,Merge,Mercurial,Branching And Merging,几个月前,我根据默认设置创建了br1分支。从那时起,我一直在提交并推动对br1的更改。每隔一段时间,从默认值拉入更改,如下所示: hg up br1 hg merge default // create a commit, push 我想创建一个提交消息,其中包含我在过去几个月对br1所做的所有更改。分支br1和默认值在我的工作区中是干净的,即没有未提交的更改,没有未推式提交。此时,br1与默认值不同步1周。我执行了以下步骤: hg up default hg merge br1 // At

几个月前,我根据默认设置创建了br1分支。从那时起,我一直在提交并推动对br1的更改。每隔一段时间,从默认值拉入更改,如下所示:

hg up br1
hg merge default
// create a commit, push
我想创建一个提交消息,其中包含我在过去几个月对br1所做的所有更改。分支br1和默认值在我的工作区中是干净的,即没有未提交的更改,没有未推式提交。此时,br1与默认值不同步1周。我执行了以下步骤:

hg up default
hg merge br1
// At this point, "hg stat" shows files that I did not modify in br1. :(
// So, if I created a commit message at this point, it would be no good.
// I am not sure why these addition file modifications showed up.
我认为问题可能是因为br1在一周内与默认值不同步。我在干净的工作区中执行了以下步骤:

hg up br1
hg merge default
// created a commit -**ch1**, but did **NOT push**
hg up default
hg merge br1
// At this point, "hg stat" shows the same additional files as my pervious
// attempt. :(
问题: -“hg merge”是否忽略未推送的提交? -要使这些附加文件不显示,是否需要按ch1?这就是为什么在执行“hg merge br1”时会显示其他文件的原因吗? -有没有一种方法可以让hg在从br1进行合并时考虑ch1

谢谢,,
Ahmed.

既然您没有提供一个有效的示例,我就必须从头开始构建一个,请原谅我下面的一大堆命令行

最后给出解释,因为只有遵循示例步骤,才有意义

准备舞台

为什么? 因为在某个时刻,
“def”
br1
中进行了更改,而
default
从来都不知道它,所以即使您很长一段时间没有接触
dummy.txt
,您也已经将
default
同步到
br1
,但没有其他方法,因此
default
有很多东西需要跟上

编辑:在OrtoisehG中添加了此场景的屏幕截图

非常感谢您的解释和工作示例。问题,对于场景1,我猜测hg stat将类似于“dummy.txt被修改,试图从br1中引入“def”,并且出现了另一个新文件。这正是我想要的。对于这两个项目,是在br1上所做更改的完整列表。建议使用什么样的工作流来仅获取添加到bri的更改列表(将“def”添加到dummy.txt),并创建另一个新文件。是否有一个推荐的工作流程。为了更好地可视化和理解正在发生的事情,我建议您使用TurtoiseHG(GUI),同时您可以参考另一个注意事项,为了简化合并,最好先将
default
合并到
br1
,然后使用“场景2”,在受控且更为最新的阶段解决合并冲突,然后将
br1
返回到
default
而不合并冲突got。我继续并提交了更改(从br1合并到默认值),“br1->default”。当我使用命令“hglog-r
# create a new dir an initialize the repository
mkdir hgtrial
cd hgtrial
hg init

# create an empty file and make first commit on default branch
echo . > dummy.txt
hg add dummy.txt
hg commit -m "1st commit"

# add info and make a second commmit also on default branch
echo abc >> dummy.txt
hg commit -m "2nd commit"

# create a new branch and make an empty commit on it
hg branch br1
hg commit -m "my new branch"

# work on br1
echo def >> dummy.txt
hg commit -m "def on br1"

# work on default (make br1 out of sync)
hg up default
echo ghi >> dummy.txt
hg commit -m "ghi on default"
echo jkl >> dummy.txt
hg commit -m "jkl on default"

# sync br1 by pulling default
hg up br1
hg merge default
# solve merge conflicts (abc def ghi jkl)
hg commit -m "br1 <- default"

# continue working on br1 (without touching dummy.txt)
echo 123 > another.txt
hg add another.txt
hg commit -m "another file"
echo 456 >> another.txt
hg commit -m "456"

# work on default (make br1 out of sync)
hg up default
echo yes-yes > one-more.txt
hg add one-more.txt
hg commit -m "yes-yes, on default"
echo no-no >> one-more.txt
hg commit -m "no-no, on default"
# now the problem (scenario 1)
hg merge br1
hg stat
# dummy.txt is modified, trying to bring "def" from br1 into default
# abort

# checkout clean br1 (drop merge in progress)
hg up -C br1
hg merge default
hg commit -m "br1 <- default"

# the problem again (scenario 2)
hg up default
hg merge br1
hg stat
# dummy.txt is modified, trying to bring "def" from br1 into default
# SAME THING!