Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

trouble in using "git commit -a" command

I am trying to commit all my changes by using following command

git commit -a

Note : I want to commit without any "commit message"

but when I execute above command it shows me the screen shown below, and I don't know how to get out of this screen to complete my commit.

enter image description here

like image 904
Tahir Yasin Avatar asked Oct 31 '12 13:10

Tahir Yasin


People also ask

How do I run a git commit command?

Git commit -m The -m option of commit command lets you to write the commit message on the command line. This command will not prompt the text editor. It will run as follows: $ git commit -m "Commit message."

How do I fix my commit?

You can modify the most recent commit in the same branch by running git commit --amend. This command is convenient for adding new or updated files to the previous commit. It is also a simple way to edit or add comments to the previous commit. Use git commit --amend to modify the most recent commit.

How do I force a git commit?

The --force option for git push allows you to override this rule: the commit history on the remote will be forcefully overwritten with your own local history. This is a rather dangerous process, because it's very easy to overwrite (and thereby lose) commits from your colleagues.


2 Answers

You must specify a commit message with each commit. There are two ways to do this. First, you can provide it on the command line, using the -m switch:

git commit -am "I made the changes"

If you don't specify that switch, git opens the configured editor. By default, this is vim. To write the message in vim, type i to enter insert mode, then type your message. Hit esc to exit insert mode, then type :wq to save (write) and quit the editor.

You can also configure another editor to be used by git. On the command line, you can run a command like git config --global core.editor notepad, where notepad is the name of the editor that you prefer.

like image 164
bdukes Avatar answered Oct 05 '22 23:10

bdukes


try git commit -a -m '[your commit message]'

edit: git need always a comment for each commit, you can by the way add an empty comment with

git commit -a -m ''

or

git commit -am ''

Committing with a message is necessary when using Git, but is also helpful:

Crafting the commit message is a very important step of your development work. The message is usually the first thing other developers will see, and the first line in a Git commit-msg has a special meaning. It is considered the "Title" or "Subject" of the commit. Many interfaces use this title to represent the commit, such as:

-Subject of e-mail notifications

-git log's "oneline" mode

-Gerrit interface (dashboard, search results, title)

-Git revert (cites the commit title)

-Various Git GUI clients

(use first line as title until first empty line or end of body)

like image 36
dnlcrl Avatar answered Oct 06 '22 00:10

dnlcrl