2

我有以下提交/分支的结构:

|
*   03dd257 - (HEAD, solutions) ...
|\  
| * 7976266 - (master) ...
* | 9ce9158 - ...
|/  
* d2a4d81 - ...

我的流程是:

  • 提交 d2a4d81(主)
  • 创建分支解决方案
  • 提交 9ce9158(解决方案)
  • 提交 7976266(主)
  • 将 master 合并到解决方案(commit 03dd257)
  • 修改 master 上的提交 7976266

现在我的提交在大师和解决方案上有所不同。如何安全地更新分支解决方案上的提交 7976266?

这些都是本地更改,因此一旦我在本地解决此问题,推送应该没有问题。

我对解决方案分支有进一步的更改,所以我不能简单地重置为 9ce9158 并再次合并。

4

2 回答 2

0

If you do, merge commit will still point to old (not amended) commit, and your tree will look like this:

|   *  XXXXXXX - amended commit
*   |  03dd257 - (HEAD, solutions) ...
|\  |
| * | 7976266 - (old master) ...
* |/ 9ce9158 - ...
|/  
* d2a4d81 - ...

What you might want to do is reset solutions branch back to before merge and do a new merge. If you haven't published anything yet (and since you amend stuff, you probably didn't), it's OK to do so.

于 2012-12-27T11:17:07.057 回答
0

假设通过修改生成的新提交79762667976266-v2.

我想你也希望7976266-v2出现变化solutions,而不会使图表过于复杂。

首先,在以下位置创建一个amend分支7976266-v2

git branch amend 7976266-v2

然后'rebase'在和7976266之间变化7976266-v2solution

git rebase --onto solutions 7976266 amend

这应该在 之后创建一个新的提交03dd257,其中包含 和 之间的更改7976266,并且现在由分支7976266-v2指向。amend

  * sth_new - (amend)
|/
*   03dd257 - (solutions) ...
|\  
| * 7976266 - (master) ...
* | 9ce9158 - ...
|/  
* d2a4d81 - ...

amend现在您可以随时合并solutions

于 2012-12-27T11:32:22.520 回答