-
Notifications
You must be signed in to change notification settings - Fork 129
Rebase and merge pull request option should add a merge commit #1143
Comments
Note: I sent this enhancement request to [email protected] |
GitHub's response:
|
I was evaluating and was excited when they offer "rebase and merge" - but then I checked the documentation and saw that rebased merge is fast-forwarded (https://help.github.com/articles/about-pull-request-merges/):
Would be nice if there's an option to have the merged And it seems this open ticket of yours here confirms that feature isn't there yet. I wish I could vote for this feature. |
@yogasantosa I'm anxiously waiting for this feature. |
@johnnyoshika - the other thing i'm not sure either is: |
@yogasantosa |
Just for understanding: What does fast forward mean for a "Rebase" ? |
@Wildeast GitHub offers the option to Note: Rebase without fast-forward is the default merge option (GitHub calls it |
I don't think This is what is mentioned in the chapter [Rebase and merge your pull request commits]:
To clarify the git checkout master
git merge --no-ff feature
git push origin master The git checkout master
git rebase feature
git push origin master What you seems to think it's doing is: git checkout feature
git rebase origin/master
git checkout master
git merge --no-ff feature
git push origin master Basically this is This is hinted at in [Rebase and merge your pull request commits]:
So GitHub Moreover it is later mentioned:
Those constraints a due to the fact that The documentation is quite misleading because in the chapter Rebase and merge your pull request commits it's also mentioned:
This sentence seems wrong (probably of copy/paste of |
Thanks @pvdlg for the explanation. It's a lot more clear now. I was hoping that we can get a new option that did this:
|
I'm not sure it's a good idea, because after What you are asking is already possible now by doing as follow:
|
@pvdlg I just played around on a simple repo and it seems that rebasing master on top of feature branch simply adds commits from feature branch to master. At least on my mac it happens in the historical order. So it's likely that the one has to fix some conflicts during rebase and that it's a good idea to wait for the CI anyway, except it's impossible to achieve since the commits are already in master at this point. However, I guess Github shields users from such scenarios and requires manual resolution/merge etc.. It's confusing that this specific option is called "Rebase and merge" because there is no merge. That's why everyone thinks that it's a rebase on top of master with the subsequent merge to master. |
In don't understand the latter part of this thread. Rebasing master on top of feature branch would change master's commit shas if the branches diverged both sides ? It does not seem to be the case though (and hopefully so) |
Is it possible to make 'Rebase and merge' the default option? |
I would be satisfied with just a strict check requiring a PR's base to be at the target branch's HEAD before merging. An Update button would be useful if it did a rebase. Half the reason we rebase incoming branches is to remove any intermediate merge commits. We are against squashing away useful history, but for squashing away WIP commits, etc. This maintains a nice clean, serial commit flow with good history but without garbage commits and has supported our trunk based flow very well. Some of this is aesthetics -- but I think there is value in the tree being very simple and easy to visually comprehend. |
the 'Rebase and Merge' option isn't that -- it ought to be renamed, 'rebase and ff' |
I ended up here because I am in the process of experimenting with the Large Synoptic Survey Telescope workflow for another astronomy project, and it seems to be identical to what is being discussed here. An example of one of their repos in the wild is here: https://github.com/lsst-dm/fgcmcal.git It's nice because you get the clean/linear history of a purely rebased workflow, but the non-ff merge commits encode the name of the branch (which is useful for project management, and saves you having to add it to the individual commit messages). Note that the merging section from that LSST guide clearly describes the problem with the GitHub interface (and why they end up doing merges from the command-line instead). So, another vote from me to add the ability to enforce non-ff merges. |
@pvdlg commented:
This creates a merge commit from the target branch into the PR source branch. This is nearly the opposite of what is being requested. If the |
About "rebase and merge" creating a merge commit is a -1000 from me. |
It would be nice to have a fourth option equivalent to git rebase + git merge --no-ff So the three buttons (excluding squash and merge) would be : |
I is being discussed for half of the lifespan of GitHub here and there. Is there a bad architecture violation / performance bottleneck we all overlook here which blocks GitHub from just adding an option? |
+1 for Rebase, Squash and Merge with --no-ff |
Id like to see another rebase option. One that doesn't create a new set of SHAs. Every time I rebase merge, I now have to either delete my feature branch, or manually reset + force push it to get to the same point as the base branch. |
Isn't that's the regular merge option? If you rebase, by definition the commit SHAs of the branch will change (because their ancestry chain, which is part of what determines their hash, changes when you change the base commit of a branch). Unless I misunderstood what you mean? |
Gotcha — you're saying that if the PR branch is already up-to-date, a "rebase and merge" should only do a fast-forward merge, rather than force a rebase (which implies making copies of the commits) even though it isn't needed. I agree that an option to do fast-forward merges would be desirable, although I'd prefer to see that as a separate option called explicitly "fast-forward merge", to avoid exacerbating the merge vs. rebase confusion that's already quite common. |
Please add "Rebase and merge with |
Github, please add this necessary feature! |
Or simply hire me for 0$ until I manage to make this feature come to life 😅 |
Azure devops also has this feature, when will you implement this feature? This strategy is the most exotic – it’s a mix of rebase and a merge. First, the commits in the pull request are rebased on top of the master branch. Then those rebased pull requests are merged into master branch. It emulates running git rebase master on the pull request branch, followed by git merge pr --no-ff on the master branch. Some people think of this as the best of both worlds: individual commits are retained, so that you can see how the work evolved, but instead of just being rebased, a “merge bubble” is shown so that you can immediately see the work in each individual pull request. |
I honestly think that #1017 has a much cleaner description and scope. It requests that a new, fourth alternative is added ("Create merge commit with semi-linear history"). |
I agree, this has ended up being exactly the feature request that #1017 is - and as pointed out previously, it in better detail in #1017, is that is already implemented in other git servers out there, and even Azure DevOps also owned by Microsoft. ;) I'd really like to see this added, even with a "lock this repo to ONLY use this option". :) Merges should then always be the PR description, and you're good to go on delving in all you want on how files have changed. Should these two issues be merged? If so, I vote for #1017 to be the main one going forward. |
Is this requested feature similar to |
@farislr No.
It has nothing to do with semi-linear merge which implement by rebase first, then no-fast-forward merge. |
The thing about merge commits themselves is that they are empty and useless to me, for starters I like my tree to be linear and rebase and merge does that. Now I would love it if there was a new button however and that is rebase + squash, I think that is also a thing I would really love as well. For starters I think having rebase and merge doing a merge commit is a good thing, but only for projects who have policy to make them, some people prefer rebase and merge without merge commits and so they say "create merge commit, you fired!". |
@AraHaan If you rebase first, the "non-linearity" introduced by a merge commit is really negligible. It's the non-rebased merges that make the commit tree look awful. And the merge commit is not completely useless, it (put simply) groups the commits that belonged to a single PR and it may contain a link to that PR. Then a person analyzing the history of a git repo, looking for some information, may find something useful in the comments that were made when reviewing the PR. All of that in addition to some formal requirements (e.g. gov projects that need to be able to prove a formal review process was made for each and every change) that some repositories may need to fulfill, as you have very aptly observed. |
On my projects I set mine up on rebase and merge to include |
@AraHaan From my experience, I never use the squash feature. It's weird to drop the history commits. |
@chucklu actually it can be done, on mergify I set my update strategy from |
@AraHaan semi-linear is Let me show you an example if you use "rebase+squash", it means rebase first then squash |
Sometimes when 2 prs are merged at almost the same millisecond the second one might actually try to merge in a conflicted change while a rebase and then the squash as a button could resolve the conflict by having it know of the changes previously merged just prior without needing to wait for the checks to pass again (and as such uses less github actions minutes then). While chances of conflicts could possibly be low it can possibly happen even when we do not realize it at that moment until the automated merges leaves that branch in a non-buildable state with some possible merge conflict annotations in some files. When I do things like this locally I usually avoid merge conflicts by |
@AraHaan Have no experience on auto merge(who review the code?), how could it resolve the conflict? From my experience the conflict always need to resolve manually.
The 2 prs should be arranged in a queue, and then it can be done one by one. |
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. |
I can't believe this is not a feature, we have been using bitbucket for years and the rebase + merge commit is important for all the reasons mentioned here (auditability, easy to revert a single merge commit rather than 50 individual commits etc..) Make it at least an option so all the people who work on toy projects that don't need a merge commit don't feel offended, but at least for people that work in large teams with lots of contributors, allow us to have rebase with a merge commit ! |
@nrjohnstone Actually this is not an official issue tracker for github, you can send feedback to github via https://support.github.com/contact/feedback |
@tmedioni, this is why GitHub won't allow you to merge in any fashion whatsoever with their shiny green buttons when there is any merge conflict whatsoever between the head and base branches.
@chaoliu2002, @JohnyWS sort of, but unfortunately only by making it the only option using the settings described here. |
+1 Rebase on master and then merge without fast forward yields a very nice and readable history where you can easily see all the pull request merges having been done. To those that think that the history should be linear: I envy you for already having your option and I don't want it taken away. So there should be a new option, or a configuration for deciding whether "Rebase and merge" should use --no-ff. Preferably a new option. To those thank think rebasing and creating a merge commit could break tests and whatnot. Well, of course, but what do you think the existing "Rebase and merge (with fast-forward)" could do? |
Here are the options for merging pull requests:
Selecting the first one (Create a merge commit) will create a new merge commit so that you can easily tell that a merge was done through a pull request when you look at
git log
. TheRebase and merge
option, however, won't create a merge commit. I think it should do so. So in other words,Rebase and merge
should first rebase, and then do the same thing as theCreate a merge commit
option.The text was updated successfully, but these errors were encountered: