How can I commit changes without specifying commit message? Why is it required by default?
相关问题
- Why does recursive submodule update from github fa
- Extended message for commit via Visual Studio Code
- Emacs shell: save commit message
- Can I organize Git submodules in a flat hierarchy?
- Upload file > 25 MB on Github
相关文章
- 请教Git如何克隆本地库?
- GitHub:Enterprise post-receive hook
- Git Clone Fails: Server Certificate Verification F
- SSIS solution on GIT?
- Is there a version control system abstraction for
- ssh: Could not resolve hostname git: Name or servi
- Cannot commit changes with gitextensions
- git: retry if http request failed
The commit message is a best practice that should be followed at all times. Unless you're the only developer and that isn't going to change any time soon.
Git requires a commit to have a comment, otherwise it wont accept the commit.
You can configure a default template with git as your default commit message or can look up the --allow-empty-message flag in git. I think (not 100% sure) you can reconfigure git to accept empty commit messages (which isn´t such a good idea). Normally each commit should be a bit of work which is described by your message.
git generally requires a non-empty message because providing a meaningful commit message is part of good development practice and good repository stewardship. The first line of the commit message is used all over the place within git; for more, read "A Note About Git Commit Messages".
If you open Terminal.app,
cd
to your project directory, andgit commit -am ''
, you will see that it fails because an empty commit message is not allowed. Newer versions of git have the--allow-empty-message
commandline argument, including the version of git included with the latest version of Xcode. This will let you use this command to make a commit with an empty message:Prior to the
--allow-empty-message
flag, you had to use thecommit-tree
plumbing command. You can see an example of using this command in the "Raw Git" chapter of the Git book.When working on an important code update, if you really need an intermediate safepoint you might just do:
or shorter:
Note: starting git1.8.3.2 (July 2013), the following command (mentioned above by Jeremy W Sherman) won't open an editor anymore:
See commit 25206778aac776fc6cc4887653fdae476c7a9b5a:
git 2.9 (June 2016) improves the empty message behavior:
See commit 178e814 (06 Apr 2016) by Adam Dinwoodie (
me-and
).See commit 27014cb (07 Apr 2016) by Jeff King (
peff
).(Merged by Junio C Hamano --
gitster
-- in commit 0709261, 22 Apr 2016)And if you add an alias for it then it's even better right?
Now you just do an nccommit, nc because of no comment, and everything should be commited.