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
- Method 2: Divide Commit Messages into Multiple Lines Using the “-m” Option Multiple Times
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:
file
added"
Then, display the commit history to see the desired commit message:
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:
Then, view the commit message by checking the commit history:
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.