1

これらのコミットを時系列で持っているとしましょう:

  1. a
  2. b
  3. c

b今、私は cを取り除きたいのですが、私が持っているように:

  1. a
  2. c

どうすればいいですか?

b( と の間に競合はありませんc)

4

4 に答える 4

2

すでに変更をリモートにプッシュしている場合は、次を使用できます。

$ git revert <hash of commit b>

dコミットの変更を削除する新しいコミットを作成するb

于 2012-04-03T20:41:51.737 に答える
0

HEAD からのコミットが 1 つだけ必要な場合は、別のブランチで cherry-pick を使用して、そのコミットだけを持ち込むことができます。

$ git checkout -b working
$ git reset --hard <hash of the commit `a`>
$ git cherry-pick <hash of the commit `c`>

ハードリセットは作業コピーをそのコミット時の状態に戻し、チェリーピックはコミットで導入された変更をc作業コピーの上に直接適用します。

于 2012-04-03T20:22:16.277 に答える
0

git rebase のヘルプは、まさにこのケースについて語っています! 見てみな:

A range of commits could also be removed with rebase. If we have the
   following situation:

           E---F---G---H---I---J  topicA

   then the command

       git rebase --onto topicA~5 topicA~3 topicA

   would result in the removal of commits F and G:

           E---H'---I'---J'  topicA

   This is useful if F and G were flawed in some way, or should not be
   part of topicA. Note that the argument to --onto and the <upstream>
   parameter can be any valid commit-ish.
于 2012-04-03T20:47:31.990 に答える
0

まだリモート リポジトリにプッシュしていないと仮定すると、インタラクティブなリベースを実行できます。ここを参照してください:

http://book.git-scm.com/4_interactive_rebaseing.html

于 2012-04-03T20:19:20.700 に答える