3

次の Git 履歴があります。

    D-E-A-B-C-A-B-C (feature2)
   /
  *-D-E (feature1)
 /
*-F (develop)

A、B、および C が feature2 で 2 回使用された方法がわかりません。と を使用して、feature1 のオンとオフで feature2 をリベースしていgit rebase feature1ますgit rebase --onto develop feature1。私は A、B、C を選択して新しいブランチを開発することで状況を修正しましたが、これはどのようにして発生したのでしょうか? 私は困惑しています。


編集

ここで Github が何をしているのかはわかりませんが、Git は次のように言っています。

Your branch and 'origin/feature2-fresh' have diverged,
and have 113 and 100 different commit(s) each, respectively.

Githubのせいだと思われますか?

4

2 に答える 2

4

Here's what happened:

  • So I rebased feature2 onto feature1.
  • I rebased feature2 back onto develop.
  • I pushed feature2, then realised there was more work to do, so did the rebase dance again (feature1 was needed to run feature2).

Now the SHA-1s of all the commits unique to feature2 are different to the corresponding commits on origin/feature2.
Without realising, I do a pull. Git dutifully merges all the commits again, because they have different SHAs. The moral of the story is:

Don't rebase a pushed branch.

于 2013-01-07T14:35:12.847 に答える
1

1 つの可能性:
重複したコミットは、git cherry-pick(" git - what is cherry-pick? " とその重複したコミットの問題を参照してください) の証拠となる可能性があります。

A と B がリベース後の任意の時点でチェリー ピックされた場合、ブランチに既に A と B が含まれていても (SHA1 が異なる)、それらを feature2 に追加できます。

A と B がリベースのにチェリーピックされた場合、A と B は繰り返されるべきではありません ( git rebaseman ページから)

アップストリーム ブランチにすでに行った変更が含まれている場合 (たとえば、アップストリームに適用されたパッチをメールで送信したため)、そのコミットはスキップされます。

于 2013-01-07T10:28:01.313 に答える