You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/workflow/gitlab_flow.md
+6-5Lines changed: 6 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -187,12 +187,15 @@ If you have an issue that spans across multiple repositories, the best thing is
187
187

188
188
189
189
With git you can use an interactive rebase (`rebase -i`) to squash multiple commits into one and reorder them.
190
+
In GitLab EE and .com you can also [rebase before merge](http://doc.gitlab.com/ee/workflow/rebase_before_merge.html) from the web interface.
190
191
This functionality is useful if you made a couple of commits for small changes during development and want to replace them with a single commit or if you want to make the order more logical.
191
192
However you should never rebase commits you have pushed to a remote server.
192
193
Somebody can have referred to the commits or cherry-picked them.
193
194
When you rebase you change the identifier (SHA-1) of the commit and this is confusing.
194
195
If you do that the same change will be known under multiple identifiers and this can cause much confusion.
195
196
If people already reviewed your code it will be hard for them to review only the improvements you made since then if you have rebased everything into one commit.
197
+
Another reasons not to rebase is that you lose authorship information, maybe someone created a merge request, another person pushed a commit on there to improve it and a third one merged it.
198
+
In this case rebasing all the commits into one prevent the other authors from being properly attributed and sharing part of the [git blame](https://git-scm.com/docs/git-blame).
196
199
197
200
People are encouraged to commit often and to frequently push to the remote repository so other people are aware what everyone is working on.
198
201
This will lead to many commits per change which makes the history harder to understand.
@@ -221,13 +224,11 @@ You can reuse recorded resolutions (rerere) sometimes, but without rebasing you
221
224
There has to be a better way to avoid many merge commits.
222
225
223
226
The way to prevent creating many merge commits is to not frequently merge master into the feature branch.
224
-
We'll discuss the three reasons to merge in master: leveraging code, solving merge conflicts and long running branches.
227
+
We'll discuss the three reasons to merge in master: leveraging code, merge conflicts, and long running branches.
225
228
If you need to leverage some code that was introduced in master after you created the feature branch you can sometimes solve this by just cherry-picking a commit.
226
229
If your feature branch has a merge conflict, creating a merge commit is a normal way of solving this.
227
-
You should aim to prevent merge conflicts where they are likely to occur.
228
-
One example is the CHANGELOG file where each significant change in the codebase is documented under a version header.
229
-
Instead of everyone adding their change at the bottom of the list for the current version it is better to randomly insert it in the current list for that version.
230
-
This it is likely that multiple feature branches that add to the CHANGELOG can be merged before a conflict occurs.
230
+
You can prevent some merge conflicts by using [gitattributes](http://git-scm.com/docs/gitattributes) for files that can be in a random order.
231
+
For example in GitLab our changelog file is specified in .gitattributes as `CHANGELOG merge=union` so that there are fewer merge conflicts in it.
231
232
The last reason for creating merge commits is having long lived branches that you want to keep up to date with the latest state of the project.
232
233
Martin Fowler, in [his article about feature branches](http://martinfowler.com/bliki/FeatureBranch.html) talks about this Continuous Integration (CI).
233
234
At GitLab we are guilty of confusing CI with branch testing. Quoting Martin Fowler: "I've heard people say they are doing CI because they are running builds, perhaps using a CI server, on every branch with every commit.
0 commit comments