Search code examples
gitgit-commit

git commit -m not working


I have been committing to my local repository today with git commit -a and entering my commit messages. Everything fine.

At the end of the day I wanted to commit a small change with a single line commit, so I used git commit -m "some message" and got the following:

On branch ChartFeature
Your branch is ahead of 'origin/ChartFeature' by 2 commits.
  (use "git push" to publish your local commits)
Changes not staged for commit:
        modified:   SomeFolder/Scripts/app/SomeScript.js

no changes added to commit

What have I done wrong?

How do I get git to allow commit -m again?

Footnote: After failing with -m a few times and seeing nothing wrong with git log origin/ChartFeature..HEAD I tried git commit -a as before and it worked (as expected) though git commit -m still does not.


Solution

  • git commit -m 
    

    does only work when you did a git add something before!

    That is all there is to that! In other words: you haven't added (staged) anything; thus you can't make a commit!

    git -a
    

    adds (certain) types of changes automatically; -m does not!

    Your status messages tells you:

    Changes not staged for commit: modified: SomeFolder/Scripts/app/SomeScript.js