0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

git rebase i コミットを編集する

Posted at

最近 git rebase -iがの便利な機能を知ったのでメモとして残します。

今の git logの状態

commit cd8a4309b4e196d3fc169f10b708197c48898346
Date:   Tue May 21 09:01:15 2019 +0900

    file modified

commit f9d702a3c0f6188c780609270da917aa174d858a
Date:   Tue May 21 08:59:14 2019 +0900

    modified file

commit 321f711dc4a590fd27721523d53a69353e9daf76
Date:   Tue May 21 08:58:42 2019 +0900

    created file

1つ目と2つ目のコミットをまとめたい。

git rebase -i HEAD~2

すると以下のようなvimが立ち上がります。

pick f9d702a modified file
pick cd8a430 file modified

ここで以下のようにすると

pick f9d702a modified file
s cd8a430 file modified

こんな感じでコミットメッセージを編集する画面が表示されます。

# This is a combination of 2 commits.
# This is the 1st commit message:

modified file

# This is the commit message #2:

file modified

しかし、こんな感じにすると

pick 0f1e189 modified file
f b470369 third commit

pickされたコミットのメッセージが残ります。
少しだけ時短

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?