rebase は便利
commitの順番を変えたい時
[code lang=text] $ git rebase -i master [/code]
もしくはcommitの数だけ ~ を書く
[code lang=text] $ git rebase -i HEAD~~~~ [/code]
で今回は id renameのところに実はid rename2も入れたかったとする git rebaseコマンドで下記のようにでてくる
[code lang=text] pick 6879baf04 astel_app id rename pick 925ca77d1 astel_app added uid_count pick 6b6a9c3e6 astel_app id rename2
Rebase a226abaaf..6b6a9c3e6 onto a226abaaf (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
[/code]
これを下のようにpickをfに書き換えて順番を入れ替える
[code lang=text] pick 6879baf04 astel_app id rename f 6b6a9c3e6 astel_app id rename2 pick 925ca77d1 astel_app added uid_count
Rebase a226abaaf..6b6a9c3e6 onto a226abaaf (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
[/code]
こうなる
[code lang=text] $ git log | head -n 30
commit 485d8653fba2d6cfdfaac647e917b1418c6c49e4 Author: astel <aaaaaaaastel@gmail.com> Date: Tue Jun 19 14:59:49 2018 +0900
astel_app added uid_count
commit 502b0156492b272637b75dc6d40d74590f2d6ede Author: astel <aaaaaaaastel@gmail.com> Date: Tue Jun 19 14:58:47 2018 +0900
astel_app id rename
[/code]
追記
直近のコミットコメントを消してもいいならf (って書いてるやんけ