73
62

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のcommitメッセージを複数行入れる方法

Posted at

-mオプションを使う方法

よくコミットの説明で出てくる-mのオプション。
このオプションを複数使うことでメッセージも複数になります。
ただ仕様なのかメッセージの間に1行分隙間が空いてしまうようです。

例.

$ git commit -m "hoge" -m "piyo"

結果.

commit 728861eb41697c4f7b4943f8e7215c6cf0622663
Author: User
Date:   Mon Feb 25 13:05:45 2019 +0000

    hoge

    piyo

ヒアドキュメントを使う方法

コミットの際にgit commit -F- <<EOMと入力すると、EOMと入力するまで文字を入力することができます。

例.

$ git commit -F- << EOM
> foo
> bar
> EOM

結果.

commit 401ce885fb46915d35664b88a8fbbf5ae05041c8
Author: User
Date:   Mon Feb 25 13:11:52 2019 +0000

    foo
    bar

エディタを使う方法

ターミナル上のエディタ(VimやEmacs、nanoなど)が使えるのであればこれが一番シンプルに使いやすいです。
使い方は簡単で、-mのオプションを__付けずに__コミットをするだけです。
これでGitのデフォルトに設定されているエディタ(標準ではnano)が開くので、あとは好きなように記述してエディタを終了するだけで完了です。

例.

$ git commit
Vim
hogepiyo
foobar

結果.

commit d3e81e0f05c380e4637662b302936dd07c320172
Author: User
Date:   Mon Feb 25 13:50:18 2019 +0000

    hogepiyo
    foobar
73
62
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
73
62

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?