I have problem with git like
When I do git commit
. Then I tried git commit -m
, it said to me that error: switch 'm' requires a value
I am very confused with this, could you please give me some ideas?
I have problem with git like
When I do git commit
. Then I tried git commit -m
, it said to me that error: switch 'm' requires a value
I am very confused with this, could you please give me some ideas?
-m switch indicates that you will add a commit message (commit name). When you enter -m it means you will enter a string after it like:
git commit -m "This is my first commit - I changed xy class in it"
Moreover,
git commit -a -m "add button to signup flow"
is equal to:
git add .
git commit -m "add button to signup flow"
Notes:
The message in the link indicates that at some earlier, you started writing a commit message and did not close the file (or perhaps it is open in a different terminal window). You could usually just delete the swp
file, unless you want to recover its contents. See here and here for further details.
git commit -m
expects that a commit message will follow the -m
flag, which is what gives your second error. You can do:
git commit -m "some commit message"
to complete the commit.
There are several things going on here.
This can be especially confusing for new vim users. This is, however, a vim error and not a git error. For commit messages, the solution is usually best to
:q!
):wq
or ZZ
or any of the other ways to exit vim properly). If you don’t like vim, configure git to use another editor. (These last two statements have highly upvoted SO questions, if you google.)NOTE I do not necessarily recommend off-hand deletion of swap files any time there is an issue.
vimtutor
and at least try vim out ;) ). Probably thinking -m
would use their already typed message, they tried it. However, according to git help commit
, -m
requires the message as an argument to the command. I do not recommend the -m
form generally, as one line is not enough for most git commits.