Home > front end >  What git commit message that fixes bad code?
What git commit message that fixes bad code?

Time:04-04

I commited and pushed my code to gitlab and then found that the code was not written well. What should I write as a commit message that fix/ clean up that bad code?

just "fix bad code"?

CodePudding user response:

Think about someone looking at your change five years from now. They can see what you did, but they don't know why. Your commit message explains the why, and the context of what you did to this person (who may be you).

Your commits should be small enough that you can provide a summary of what you did.

Use Semantic Commit Messages to provide a general structure.

fix would be for fixing a bug.

fix: Forgot to strip whitespace before handling user input

refactor would be for redesigning code.

refactor: Redesign the Frobniz system

Frobniz was too complicated, so I extracted it into
Frobniz::Parse and Frobniz::Push. Frobniz delegates to
these objects now.

Maybe you forgot to add documentation.

docs: adding documentation to Frobniz

CodePudding user response:

You can have your commit message as whatever you like, as long as it describes what the commit is doing.

  • Related