How to Commit the code in git without adding the Commit Message?

Github or any git server which provides you to commit your code need a commit message or commit instruction to commit your code through git client or their respective consoles.

The most common way which IT industry uses to commit the code to repository like github is through git client CLI.

well it is obvious that whenever you want to merge your commit to codebase it needs to be reviewed to check if it’s according to standard or not or if there is any vulnerability.

In review there is a possibility that your code needs some further changes needs to be made and for that you need make new commit on the top of existing commit.

but what if your company or team policy allows you to have only one commit message.

well you might be having a questing why only one commit message? there is a reason for having a only one commit message it improve the log reading i.e it helps us to track the changes made by individual in single commit message.

There are different ways we can have the single commit message in our PR either at the time of commiting or if your squashing the multiple commits here we will going to discuss the first approach.

Steps:

  1. suppose you are commiting your code for first time you will going to use the below command.

2. now you need to need push these changes to repo

or if the branch is not available in remove but only in local use below command

above command is going to create a branch in remote then you can push the code to the created branch.

Commiting Code without adding commit message

now you need to add few extra lines of code in push commit without adding the commit message well very simple

execute the below command in git client cli

above command is going to commit your code without adding the commit message

next you need to push your changes to remote

NOTE: remember you need to force push the changes to remote otherwise it will not work.

and that’s it you are ready to got.

#GIT

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store