How to 'git commit' a single file/directory

I tried the following command:

git commit path/to/my/file.ext -m 'my notes'

And received an error in Git version 1.5.2.1:

error: pathspec '-m' did not match any file(s) known to git.
error: pathspec 'MY MESSAGE' did not match any file(s) known to git.

Is that incorrect syntax for a single file or directory commits?

Answer:

Arguments were expected in this order...

git commit -m 'my notes' path/to/my/file.ext

And it's not strict any more :)


Your arguments are in the wrong order. Try git commit -m 'my notes' path/to/my/file.ext, or if you want to be more explicit, git commit -m 'my notes' -- path/to/my/file.ext.

Incidentally, Git v1.5.2.1 is 4.5 years old. You may want to update to a newer version (1.7.8.3 is the current release).


Try:

git commit -m 'my notes' path/to/my/file.ext 

of if you are in the current directory, add ./ to the front of the path;

git commit -m 'my notes' ./path/to/my/file.ext 

If you are in the folder which contains the file

git commit -m 'my notes' ./name_of_file.ext