LoginSignup
0
0

More than 5 years have passed since last update.

細かいcommitをまとめたい時のgit rebase -i

Last updated at Posted at 2018-06-25
  1. git log --graph --onelineなどでrebaseしたいコミット対象を確認
* 636dfb4 [add]initial commit
* 62cc37c [add]initial commit
* ddcc7db [add]initial commit

2.git rebase -i [戻りたい対象のcommit id] で編集。

// 実行する
$ git rebase -i ddcc7db

// 以下のようなメッセージが出るので、下のCommandsに合わせてまとめるなどする
pick ddcc7db [add]initial commit
fixup 62cc37c [add]initial commit
fixup 636dfb4 [add]initial commit

# Rebase ddcc7db..636dfb4 onto ddcc7db (3 commands)
#
# 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
# d, drop = remove commit
#
# 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

3.git push -f で反映。(conflictに注意)

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