What is a Good (Git) Commit?

Viết bởi Ông Già Coder EB vào 2024-08-03
Chủ đề:

A_professional_and_clean_featured_image_for_a_blog_post.png

In software development, version control systems like Git are essential for managing changes to the codebase. At ShareWis, we have a good Git workflow. It has many steps, but with some automation tools, it is still comfortable to use. After setting up a good Git workflow, we need to define what makes a good commit and a good pull request.

For pull requests, it’s best if they don’t include too many changes. Avoid having too many files with hundreds of lines of changes. Ideally, a pull request should have only one commit. We will discuss more details about good pull requests in a future post. So, what is left to work effectively when collaborating as a team is to have a good commit. In this article, we will talk about the characteristics of a good commit.

But why is a good commit important?

Characteristics of a good commit

Good commits with Title:

Commit 1: SWWB-6685 - Refactor PaymentService: Course Subscription by Stripe Part
Commit 2: SWWB-6685 - Add new StripeService::CourseSubscriptionPurchase
This new service handles the Course Subscription Purchase using PaymentIntent, allowing for transaction “rollback” if a failure occurs.
Commit 3: SWWB-6685 - Add RSpec Tests to StripeService::CourseSubscriptionPurchase

Writing Effective Commit Messages

Best Practices for Making Commits

In conclusion, following good commit practices is important for keeping our codebase clean and efficient. By making small, clear changes and writing good commit messages, we help our team work better together. Each commit should keep the code working to avoid problems later. These habits make code reviews and debugging easier and improve the overall quality of our code. At ShareWis, using these best practices in our Git workflow will help us work more effectively as a team and keep our code at a high standard. Good commits are the foundation of a healthy codebase and a productive development environment. Let’s make every commit count and keep our projects running smoothly.