![]() ![]() ![]() These guidelines are extracted from an article written by Tim Pope back in 2008. Preceded by a single space, with blank lines in Typically a hyphen or asterisk is used for the bullet, Summary from the body is critical (unless you omit the bodyĮntirely) tools like rebase can get confused if you runįurther paragraphs come after blank lines. Line is treated as the subject of an email and the rest of More detailed explanatory text, if necessary. Short (50 chars or less) summary of changes The official git contributing page has some guidelines: There are hundreds of articles trying to define a good commit messsage and trying to teach the programmer the art of writing a good commit message. Requirement two is a very well-known problem. Let's use another more practical example: you are fixing a bug, so we want the changes to the software to be committed along with the regression tests, not in different commits that are not related to each other. Although this seems obvious, I've seen commits that change the compilation script as well as introduce a new feature in the app. A commit should represent an atomic change, and you should avoid combining multiple changes that are not related each other. Requirement one should be your default coding habit. If you pick this commit independently from the history, it makes sense on its own.Provides an explanatory commit message that helps people understand the intent of the change.Combines all the code changes related to a single logical change (it could be a feature, a bugfix, or an individual change part of a bigger change).It's hard to perfectly define what makes a commit a good commit, but in my experience, a good commit satisfies at least the following requirements: It's important to write good commits because they are the pillar of your git history. For the sake of simplicity, let's say the farther the commit is in the repository history, the more complicated it is to rewrite it. Technically there are ways to rewrite the history, but there are several reasons you generally don't want to do it. The main reason we decided to give -squash merge a try was to improve repository commit history quality.Ĭommits are essentially immutable. git has already prepared the commit message to contain the messages of all the squashed commits. You will need to execute git commit to create the merge commit. Note that git merge -squash prepares the merge but does not actually make a commit. Squashing retains the changes but discards all the individual commits of the bugfix branch. Where CDE is a single commit combining all the changes of C + D + E. If master has not diverged from the branch, when it's time to merge git will simply move the reference of master forward to the last commit of the bugfix branch. For simplicity, we'll assume we want to merge a branch containing our changes called bugfix into the branch master. ![]() For more in-depth explanations, take a look at the documentation for git merge.įirst of all, the purpose of git merge is to incorporate the changes from another branch into the current one. Note: this is definitely not a comprehensive explanation of the git merge command. git merge: fast-forward, recursive, and squashīefore we get into the details of why we adopted the -squash merge, let's have a quick look at the most common merge strategies in git. In this post I will highlight the reasons for this decision, how it worked for us, and what the benefits are. For most core repositories, such as the DNSimple web application, or our Chef-based infrastructure, our policy is to not commit to master, but make changes into a separate branch, open a pull request, obtain a review from one or two people (depending on the change), and then merge the branch into master before deploying.Ī little more than two years ago, we decided to change the development team's workflow to always use git -squash merge. At DNSimple we use pull-requests every day as a standard workflow to propose, review, and submit changes to almost any git repository. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |