Skip to content

Instantly share code, notes, and snippets.

@yanaokahiroki
Last active August 6, 2022 22:59
Show Gist options
  • Save yanaokahiroki/669873d994459cfe0f451281d14b55ef to your computer and use it in GitHub Desktop.
Save yanaokahiroki/669873d994459cfe0f451281d14b55ef to your computer and use it in GitHub Desktop.
add→commit

概要

addしてcommitしてpushする。

そのとき新規追加されたファイルを除いてindexに追加したかった。

調べたら2通りのやり方がありました。

コマンド

1.addしてcommit

git add -u のオプション -u--update の省略です。

更新されたファイルのみindexに追加します。

(=過去にcommitしたことがあるファイルのみ)

git add -u
git commit -m "commit message"
git push

2. commitコマンドだけ

addするのが面倒なとき使えそうです。

git commit -a のオプション -a--all の省略です。

変更と削除されたファイルのみindexに追加してcommitします。

git commit -am "commit message"
git push

参考

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment