git rebase
を使う
修正したいコミットのIDを確認
git log
修正したいコミットを指定
修正したいコミットの一個前のコミットIDを指定する
そして少し待つ
git rebase -i <commit>
-i
は--interactive
の略で、対話的にリベースする
修正したいコミットをedit
に変更
以下のように指定したコミットより後のコミットが表示される
pick gh21f6d ヘッダー修正
pick 193054e ファイル追加
pick 84gha0d README修正
pick
の部分をedit
に変える
edit gh21f6d ヘッダー修正
pick 193054e ファイル追加
pick 84gha0d README修正
保存はctl + x
の後、yes/noを聞かれるのでY
を押してエンター
ファイルを修正
タイトルだけ変えたい場合はここでは何もしない
修正を反映
git commit --amend
rebase
を実行
git rebase --continue
こんな感じの文章が出てくる
$ git rebase --continue
Successfully rebased and updated refs/heads/refactoring.
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
error: The last gc run reported the following. Please correct the root cause
and remove .git/gc.log.
Automatic cleanup will not be performed until the file is removed.
warning: There are too many unreachable loose objects; run 'git prune' to remove them.