Git

How Can I Make Git Commit Messages Divide Into Multiple Lines

In Git, a commit message is a short description that explains the modifications made to the source code in the particular commit. Whenever changes are made in the project, users save those changes by committing them along with the desired commit message. However, the long commit messages can be difficult to read and understand while reviewing the code changes in the commit history. Thus, dividing the commit message into multiple lines permits developers to provide a clear and brief summary of the modifications.

This study will explain the methods to divide commit messages into multiple lines.

How to Make Git Commit Messages Divide Into Multiple Lines?

Different methods can be used to divide Git commit messages into multiple lines, such as:

Method 1: Divide Commit Messages into Multiple Lines Using the “Enter” Key

To divide a commit message into multiple lines, utilize the following command and hit the “Enter” key in the terminal for a new line. The commit message will not end until you put the closing quotes:

git commit -m "Test1
file
added"

 

Then, display the commit history to see the desired commit message:

git log

 

In the below output, it can be seen that the commit message has been divided into three lines:

Method 2: Divide Commit Messages into Multiple Lines Using the “-m” Option Multiple Times

Specify the “-m” option in the “git commit” command as many times you want to divide the commit message:

git commit -m "Test2 " -m "file" -m "added"

 

Then, view the commit message by checking the commit history:

git log

 

As you can see, the commit message has been divided into multiple lines successfully:

That was all about dividing the commit message into multiple lines in Git.

Conclusion

To make Git commit messages divide into multiple lines, different methods can be used, such as dividing the commit message into multiple lines using the “Enter” key or specifying the “-m” option multiple times. This study explained the methods to divide commit messages into multiple lines.

About the author

Laiba Younas

I have done bachelors in Computer Science. Being passionate about learning new technologies, I am interested in exploring different programming languages and sharing my experience with the world.