I created the following alias on Windows 10 to issue a commit -am <commit message> command. I used the the $1 token to register an argument, but it is not working.
git config --global alias.cam 'commit -am $1'
Issuing the following command returns the error message below:
git cam "test commit"
Error Message:
fatal: paths 'test commit ...' with -a does not make sense
How do I make this work? I researched how to use arguments in git aliases, but none of the resources offers a simple solution to my problem. Thanks.
This is the rule for Git beginners: do not use
git commit -a.This is the rule for advanced Git users: do not use
git commit -aunless:git add -ubeforegit commit, andgit commit -a.From your comment:
The problem here is that
git commit -ais not likegit addfollowed bygit commit. It's more likegit add -ufollowed bygit commit(but even then, still not exactly the same). Specifically,git add -uwill only update files that Git already knows about. Theuin-ustands for update, i.e., don't add any untracked files, but do update all tracked ones as appropriate.You have an untracked file that you'd like to add. You must use
git addwithout the-uoption to do this. (Technically there are several other commands that could get you there, butgit addis the one to use.)