0
0

ステージングエリアの省略 "git commit -a" オプション"-a"について

Posted at

記事の目的

  • git commit -a コマンドについて記載
  • 便利でちょっと危ないオプション"-a"について扱う
  • Pro Gitを基に記事を作成しました。
  • 後ほど記事の改修しやすいように元の記事から分離しました。

本文

  • git commit-aオプションを指定すると、追跡対象となっているファイルを自動的にステージしてからコミットを行える。つまり git add を省略できる。
  • 注意点:変更したファイルを全てコミットできるので便利だけど意図しない変更をコミットすることもある。
$ git status
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working
directory)

  modified:   CONTRIBUTING.md

no changes added to commit (use "git add" and/or "git commit -a")
$ git commit -a -m 'added new benchmarks'
[master 83e38c7] added new benchmarks
 1 file changed, 5 insertions(+), 0 deletions(-)

オプション -a が無いのならば、 git addしてからコミットしなければならないけどそれを省略できる。

参考文献

Gitについてのリンク

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