user image

Shilpa
Published in : 2022-03-02

Is it possible to git commit files without adding a message or comments?

General

I am making code changes, where my development work is still ongoing, I want to push some files without adding a comment for those comment history.

Is it possible to commit a file excluding the message for the commit? Any other suggestions are also most welcomed to achieve this requirement!

Comments

Eslam Zedan Date : 2022-03-02

Best answers

8

Best answers

8

you can commit with an empty comment but it is not a good practice you should comment your commit so you can know why you made these changes 

here is the code for the empty commit

git commit -a --allow-empty-message -m ''

Rakshit Date : 2022-03-05

Best answers

34

Best answers

34

If you are not destroyer and want to do the things for good purpose, here is what you can use

in your git commit command, 

add parameter “--allow-empty” : No file changes

add parameter “--allow-empty-message”: Empty commit messages

Syntax: 

git commit [-a | --interactive | --patch] [-s] [-v] [-u<mode>] [--amend] [--dry-run] [(-c | -C | --squash) <commit> | --fixup [(amend|reword):]<commit>)] [-F <file> | -m <msg>] [--reset-author] [--allow-empty] [--allow-empty-message] [--no-verify] [-e] [--author=<author>] [--date=<date>] [--cleanup=<mode>] [--[no-]status] [-i | -o] [--pathspec-from-file=<file> [--pathspec-file-nul]] [(--trailer <token>[(=|:)<value>])…] [-S[<keyid>]] [--] [<pathspec>…]

Try below command to achieve your task,

git commit -a --allow-empty --allow-empty-message

Reference:  the online documentation.

Leave a comment

Join us

Join our community and get the chance to solve your code issues & share your opinion with us

Sign up Now

Related posts

docker elastic builder exited with code 127?
Publish date: 2022-02-27 | Comments: 2

Tag: General

Convert Stored Procedure of Oracle to SQL Server
Publish date: 2022-03-02 | Comments: 1

Tag: General

Connecting jupyter notebook with Android studio
Publish date: 2022-03-05 | Comments: 1

Tag: General

Difference between frontend and backend user authentication
Publish date: 2022-02-12 | Comments: 2

Tag: General

Choose default editor from filezilla on Ubuntu
Publish date: 2022-02-28 | Comments: 4

Tag: General

git issue, fatal error: your current branch appears to be broken
Publish date: 2022-03-01 | Comments: 2

Tag: General

Where can I find cheap Java and Mysql hosting server?
Publish date: 2022-05-03 | Comments: 3

Tag: General