78

GitHub でプルリクエストを行いました。現在、リポジトリの所有者は、すべてのコミットを 1 つにまとめるように言っています。

入力git rebase -iすると、メモ帳が開き、次の内容が表示されます。

noop

# Rebase 0b13622..0b13622 onto 0b13622
#
# Commands:
#  p, pick = use commit
#  r, reword = use commit, but edit the commit message
#  e, edit = use commit, but stop for amending
#  s, squash = use commit, but meld into previous commit
#  f, fixup = like "squash", but discard this commit's log message
#  x, exec = run command (the rest of the line) using shell
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out

Googleで検索しましたが、これを行う方法がわかりません。

4

4 に答える 4

73

このソリューションを探している他の誰かを助けるための簡単な追加です。スカッシュしたい以前のコミットの数を渡すことができます。例えば、

git rebase -i HEAD~3 

これにより、エディターに最後の 3 つのコミットが表示されます。

于 2013-05-20T04:29:16.093 に答える
11

を試してgit rebase -i、スカッシュしたいすべてのコミットに「スカッシュ」を使用してください。

編集:

git rebase -iリベースしているコミットのリストを含む対話型エディターが表示されます。各コミットの前のデフォルトのコマンドは「pick」であるため、スカッシュするすべてのコミットに対して s/pick/squash/ を実行するだけで、それらすべてが最後の前のコミットにスカッシュされます。

正しいブランチにリベースしていることを確認してください。

于 2013-01-26T06:13:51.143 に答える