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

Password authentication is temporarily disabled as part of a brownout.
Publish date: 2021-07-28 | Comments: 2

Tag: General

How do i r etrieve users?
Publish date: 2022-03-04 | Comments: 0

Tag: General

Unable to Connect AWS EC2 Instance with my subdirectory through domain registrar.
Publish date: 2022-02-25 | Comments: 2

Tag: General

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

Tag: General

[solved] Unable to pull updates from git "sudo git pull"
Publish date: 2021-12-20 | Comments: 1

Tag: General

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

Tag: General

Keycloak db query in source codes [closed]
Publish date: 2022-03-05 | Comments: 0

Tag: General