LoginSignup
0
0

More than 3 years have passed since last update.

単刀直入にgit rebaseのsquash

Posted at

備忘録です。

git rebase -i for squash

  1. git rebase -i HEAD~N or git rebase -i [commitHash]
    指定した数字によってHEADコミットから古い順で選ばれたコミットの数が決まります。直にコミットのハッシュを指定することも可能です。指定した一番古いコミットが選ばれたコミットに含まれます。

  2. そうしたらこのようなまとめたコミットのVIMのファイルが出てくる。

    pick d94e78 Prepare the workbench for feature Z     --- older commit
    pick 4e9baa Cool implementation 
    pick afb581 Fix this and that  
    pick 643d0e Code cleanup
    pick 87871a I'm ready! 
    pick 0c3317 Whoops, not yet... 
    pick 871adf OK, feature Z is fully implemented      --- newer commit
    
  3. そこで一番古いコミットを選択し(PICK)、他のコミットをその一番古いコミットにまとめるわけです。

    pick d94e78 Prepare the workbench for feature Z     --- older commit
    squash 4e9baa Cool implementation 
    squash afb581 Fix this and that  
    squash 643d0e Code cleanup
    squash 87871a I'm ready! 
    squash 0c3317 Whoops, not yet... 
    squash 871adf OK, feature Z is fully implemented      --- newer commit
    
  4. 次に出てくるテキストファイルでコミットのメッセージを編集することができます。(僕の場合一番新しいコミットのメッセージを残すだけ)

  5. 成功するためには必ずコミット履歴を書き換える必要になってくるのでここでgit push --forceを使います。(originに)

  6. 以上です。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0