doublejosh doublejosh - 1 year ago 135
Git Question

How to git commit a single file/directory

Tried the following command:

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

Receive an error in git version

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 there a new syntax for singe file or directory commits?

Arguments are expected in this order...

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

...however it's not even strict anymore :)

Answer Source

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 ( is the current release).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download