-
Notifications
You must be signed in to change notification settings - Fork 130
Support semi-linear merge option for pull requests #1017
Comments
Any updates here? |
I second this suggestion. Most of my projects follow the stable mainline model that relies on Right now I have to go through hoops to achieve the same thing in GitHub:
In any event, this means a lot of manual work that could and should be automated. Ideally, any CI checks should be re-run with the rebased branch before doing |
Would that include the fact to preserve commits SHAs ? Github rebasing and changing the SHA is a problem in my case to compare where a branch is ahead of another |
@K3UL The only way to keep the graph semi-linear (i.e. avoid crossing lines as in the first diagram in the opening comment) would be to rebase PR branches whose base has lagged behind the target branch, and that would necessarily change the commit hashes. But I would definitely be in favor of preserving the branch's existing commit hashes if it doesn't require rebasing (i.e. if a fast-forward merge would be possible). |
@waldyrious there already is a protected branch rule "Require branches to be up to date before merging" that enforces the PR commits to be ahead of the current master — thus already be rebased. Enabling this rule could be a requirement to be able to use merging with linear history. I think the big advantage here is: the commit being build in the PR is guaranteed to be the one that ends up being the new HEAD of master. Which is great, because there is absolutely nothing changing after the PR is closed. We already enforce this in our repos, but currently have to do this manually and merge the feature-branch by hand on our locale machine. It might be a bit cumbersome for large repos, with several PRs being open in parallel, but I think for a lot of repos, the super clean history is worth it. |
@waldyrious The problem of fast-forward merge is, you could not easily tell a merge operation from the log graph. That's why we need semi-linear merge. Semi-linear will not re-generate new commits for existing commits, when the commits can be fast-forwarded, it will only generate a new merge commit. |
If you want this feature, send it to the Github team working on PRs, merge button, etc. Take 1 minute and send your feedback via their form here: (click upvote on this comment if you've emailed them) |
For anyone watching this thread, I wrote a script to do this because I was tired of waiting on Github. Get the script here: https://pypi.org/project/git-pr-linear-merge/ It does what the original post describes: rebase, then merge without fast-forward with a simple terminal command: Documentation can be found on the project page. |
@waldobronchart the GH repo linked from PyPI is private, you might wanna change that. :) |
I gotta fix the source link, the repo is https://github.com/waldobronchart/git-pr-linear-merge
Yeah I realized it after that that was the standard name, but I don't want to rename the package now because it'll cause confusion 🤷 |
This would be equivalent to rebasing a PR without merging it (tracked as #88, most explicitly described in @jagthedrummer's comment in that thread), and then using the normal merge option (which always creates a merge commit, even if the merge could be fast-forwarded).
Such a workflow can be implemented via the command line, or using third-party tools, as @galulex illustrated here, but it would be best if it was a natively supported additional option in GitHub's web UI.
FYI, GitLab has implemented this about a year ago, and it's a popular request for Bitbucket as well.
To make this more concrete and visual, I found that the diagram from the post A tidy, linear Git history explains the difference between these workflows quite well in a visual way, and I took the liberty to add a pure linear workflow to the diagram to quickly convey the differences between
merge
vs.rebase && merge --ff-only
(linear) vs.rebase && merge --no-ff
(semi-linear):The text was updated successfully, but these errors were encountered: