سؤال

In my .gitconfig, I have the following alias:

c = add -A && git commit -m

The idea is to add all changes and commit them. However, I'm not getting success with this because Git is giving me the message error: unknown switch 'm'.

هل كانت مفيدة؟

المحلول

Bad idea. git add or even better git add -p is a great opportunity to review what you did once again before committing.

Anyway, to execute your git alias in a shell you need to use this syntax:

c = !git add -A && git commit -m

Or you could just use git commit -a which seems to be what you want. This will not automatically commit new files but do you really want to commit every single untracked file? Remember that you might have temporary stuff around which is not on gitignore. While it would be easy to undo/amend a commit that accidentally adds this kind of crap, it's better not to commit it in the first place!

نصائح أخرى

You dont need to do 'git-add', you can pass an -a flag.

git config --global alias.c 'commit -am'

So now c "commi message" should work fine.

If you just want to add it to the config file directly, its just...

c = commit -am

You probably shouldn't adopt this as the way you work regularly though. You should be looking at what you're committing before you commit it.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top