LoginSignup
4
3

More than 3 years have passed since last update.

【Git】Changes not staged for commit:とエラーが出たときの対処法

Posted at

gitでmasterブランチで直接編集した内容をcommitしようとしたとき下記のように怒られました。

masterのuser_test.rbをcommitしようとした
git commit -m "Fix test"
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
        modified:   test/models/user_test.rb

no changes added to commit

Changes not staged for commitを直訳すると「コミットのためにステージングされていない変更」になります。

最後の行は「no changes added to commit」は「コミットするために追加された変更はありません」という意味でした。

変更したものがコミットされていないと言われています。

解決策

エラーの内容通り、Addをしたら解決しました。

stagedに対象のファイルが追加されていなかったため、「コミットのためにステージングされていない」というエラーが表示されたのだと思います。

git add -A

参考

git 2.2 Git の基本 - 変更内容のリポジトリへの記録
https://git-scm.com/book/ja/v2/Git-%E3%81%AE%E5%9F%BA%E6%9C%AC-%E5%A4%89%E6%9B%B4%E5%86%85%E5%AE%B9%E3%81%AE%E3%83%AA%E3%83%9D%E3%82%B8%E3%83%88%E3%83%AA%E3%81%B8%E3%81%AE%E8%A8%98%E9%8C%B2

4
3
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
4
3