Git

How to Commit a Change With Both “message” and “description” From the Command Line?

While working on a team project, it is necessary for every team member to have a clear understanding of the changes made in the codebase. A well-written commit message and description help team members understand the context of the changes and how they fit into the overall development process. More specifically, the commit message and description provide a complete image of the changes made in the project, which is useful for debugging and troubleshooting.

This article will explain the method to commit a change including the desired commit “message” and “description” using the command line.

How to Commit a Change/Modification with Both Commit “message” and “description” in Git Using the Command Line?

To commit a change including “message” and “description”, follow the below-provided steps.

  • Redirect to the local directory.
  • Make changes in a particular file.
  • Add changes to the Git index.
  • Commit changes using the “git commit -m <message> -m <description>” command.
  • Verify committed changes.

Step 1: Switch to Local Repository

First, redirect to the desired local directory by typing out the below-provided command:

$ cd "C:Git\Repos1"

Step 2: Update File

Then, use the “echo” command and update the content of the existing file in the repository:

$ echo "This is my demo file" >> demofile.txt

Step 3: Stage Changes

Next, add new changes to the file to the Git staging area:

$ git add demofile.txt

Step 4: Commit Changes With Message and Description

Now, execute the “git commit” command along with the desired commit message and description to commit new changes:

$ git commit -m "demofile.txt updated" -m "We have added the content in demofile.txt file and updated it"

Step 5: Verify Changes

Lastly, ensure whether the changes have been committed with the message and description by viewing the Git log:

$ git log

In the below-provided screenshot, the commit message and description can be seen:

We have demonstrated the procedure of committing a change with desired commit message and description from the command line.

Conclusion

To commit a change including “message” and “description”, first, navigate to the desired local repository. Then, make changes in a particular file and add changes to the Git index. Next, run the “git commit -m <message> -m <description>” command to commit changes with the message and description. Lastly, view Git log to verify committed changes. This article has explained the method to commit changes/modifications with the desired commit message and description in Git using the command line.

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.