-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GitHub: enable squash merging / better Git history #4361
Comments
iim strictly against committing modified history - for one it makes local work flows crappier, and git is not good enough to tell the commit-er that the actual commit was merged i'd be all for this if git wasn't this barren and incapable ^^ |
Yes, it's true that OTOH
I would just like to use it for myself for example, and in cases like cited above: I think it is more important to keep the project's history in good shape. |
Would you rather like to rebase/squash the commit yourself, force-push it, wait for it to get merged, and then delete it more confidently? My main argument here is that commit history should become better, and squash-merging is a shortcut here. I think most contributors would rather have it squash-merged than being asked to force-push again, no? (just came back to this after some intermediate "linting" commit when git-blaming, so it's not just git-bisect (of course)) |
i would much rather like if git had grouping merge commits that would collapse all the elements of the second parents into a single displayed commit ^^ unfortunately thats not existing yet |
Please no. The ability to use @blueyed if you need a linear history, use |
@asottile
I get this. For bulk-cleanup I've created a (Zsh) function that compares branches and will
This just results in something like this:
Still I am not requiring to use it in general, but would only like to use it for my own PRs in the first place, and then would like to enforce something like a "every commit should pass tests by itself, and commits should be meaningful by themselves". Another benefit of squash-merging from GitHub is btw that you still have the history there (e.g. failing builds, adjustments), and then the squash-merged commit in master (also expected to be green). |
why do you care about this?
I'd rather see what actually happened.
You can already adjust the merge message, how is that different?
It's not possible to know whether your exact change was applied when using squash merge. There is no "safe" deletion of branches, you must force delete when the histories are different. Your 150 line function for handling squash merged is a 3 line bash pipeline for merges. (!!!)
If you're worried about your history, just rebase on your feature branch and merge your one tidy commit. This keeps the workflow the same for everyone (and the revert workflow the same for everyone!). It's especially common (at least in this project) for each of us to merge others' branches -- once you're squash-merging your own branches github will default that workflow for everyone elses'. You're going to end up accidentally squash merging something unintentionally :/.
Don't you lose the history because you're deleting commits? |
git-bisect and git-blame. With git-bisect it takes longer in general, and git-blame needs more steps (to
Sure, it is still valid to have multiple commits in a PR that are being kept, Also it is not worth having a "whoops, I've meant to use
Adjusting the merge message is a good point, and we/I should use this more
Yes. But you usually know a) that you had pushed your local branch, and b)
I usually do this, but rather would like the UI for it directly. Also force-pushing will a) trigger a new CI build (but you can merge When squash-merging from the GitHub UI the history is kept on the PR page.
What is the "revert workflow"?
Well, I pay attention to the state of the button in general.
The commits in the PR (remote branch, which is "archived") are not deleted, but I usually like to just keep on pushing "fixup!" and "squash!" commits, and only |
I'm not clever enough to reply and maintain the quotes, so you'll have to make do with a new post 😭 at least with git blame there's a I absolutely think it's important to keep all the history, even the small fixups. If someone cares about keeping their branch tidy, then by all means let them do that. It's insufficient to know that I pushed a branch, especially for me -- I frequently use four different computers and without being able to query reverting a merge is and lastly, I don't think relying on the github ui to maintain history is a good idea -- if we were to switch to another service all that information would be lost (but would be kept if we didn't delete commits with rebase-squash) |
FWIW, I rebase my own branches (and only my own branches) all the time, removing/squashing commits, and pushing-force back to GitHub. IIUC, all @blueyed is asking is to enable the option in the GitHub UI that allows merges to be squashed so he can use in his own branches, not to enforce us to use on all branches. As has been pointed out, he is already allowed to do so manually (and does), so why not make his life easier and allow him to do it on his own branches directly on the GitHub UI? I get @asottile's point about tracking what has been merged or not, but I understand @asottile uses this for his own branches, no? If that's the case, that workflow won't be affected. We might be derailing the discussion to personal preferences regarding merging strategies, but I think the original issue is just to enable someone to do squash-merges in the UI when merging their own branches, which they already can and do themselves manually anyway. |
It's still a problem there too, there isn't a "squash and then merge" option (which I'd be totally fine with -- not on my branches) in the UI so the overall history will be a mix of merges and squashed commits. This is worse than all-merges or all-squashes as you have to then determine "ok how was this merged" before being able to take an action (such as revert / diff / etc.) against that commit. |
Oh I see, squash in the UI is not the same operation as squash-force-push-then-merge, is that it? |
Correct, it's essentially "add one commit on master with the squashed contents of the branch" |
OK, thanks for the clarification. I'm neutral on this then, as I understand it would make @blueyed life's easier, it would make @asottile's life a little harder too. I myself prefer "clean but inaccurate history" vs "accurate but dirty history", but I'm just saying that because that everyone stated their preferences here, not to add to that discussion. 😁 |
i want to be very clear here - for me the only person that should be allowed to edit the history of a pull request is the person making it - anything else completely unacceptable in my book im entirely ok with having a process and/or expectations for cleaner history, but i am absolutely opposed to enforcing edited history on contributions of anyone |
I agree. 👍 |
Yes, @nicoddemus it is basically for me, and/or when asking contributors if it is OK to squash their commits, or if they want to do it themselves (as I would have asked for in the first example). @asottile
I do not want to handle only merges with blame/bisect, but find the bad commit - just having a bunch of extra commits that should have been squashed makes bisecting take longer, and blaming a bit more annoying (since you have to go unnecessarily to parents again).
Yes, but you could also allow others to do it, i.e. state that it is OK to squash-merge, if you do not want to do it yourself. I can see that I am a bit pedantic here, but I really do not like "bloated" history like in the first example, where none of the commits says what it is really doing. Off-topic:
You can "edit" a comment, and then copy from there.. ;) |
I'm essentially advocating these things:
And from that it follows: since a mixed history is problematic and we shouldn't force rebase-squash on people, we probably shouldn't enable rebase-squash at all. |
That's why we could just do it ourselves for them (if they are OK with it). Anyway, I am resting my case.. :) |
Like said before there is tooling for when you need this often, but in general (for the occasional PR) it is fine to use But especially given your number of repos etc you should rather not require merge commits for You could also delete local branches after the remote one has been deleted, which you usually do after merging a PR.
This does not really work unfortunaltely easily.
With
Still it feels to me like extra tooling is used for people to see a clean history (which still means that there is an unclean one). |
As for "better history": I think it is good to see WIP / tries on the PR, but have the clean result merged then. GitHub by now keeps track of forced pushes, but that is merely a note, and it is still better to see all the WIP commits that lead to the final result. I am not saying that everything should be squashed, but it certainly makes sense for things that should be (i.e. fixup commits etc), and also for single-commit PRs. |
i'm not willing to engage on the basis of this framing which i perceive as pretty passive-aggressive and needlessly annoying - feel free to rephrase the core of your message in a way that has communicative success as key target and i'm happy to engage about limited positive use of the feature |
@RonnyPfannschmidt |
I'm not going to forgive and forget, It's time this happens explicitly because the actual pattern is a problem and I expect that we engage to solve that problem As far as I'm concerned, my good will is exhausted and it's time for a number of uncomfortable non-technical negotiations about behavior |
@RonnyPfannschmidt I also appologize to all others possibly being rightfully offended directly As for speaking about behaviors and reactions in this regard I will follow-up So, again, I'm very sorry for what I've done and caused here, and I hope you will I will do what I've just should have done instead in the first place: |
@asottile Can you answer my remaining/previous comments otherwise (but also in general maybe), please? |
yes, my original comment is unchanged |
Thanks for the reply and I'm eager to sort those details out in a positive manner As for the issue at hand, That way there is control in place so contributors like @asottile and me get the control over the history as we want while we still have a reasonably simple process for helping people less fluent with git |
I'd still rather see merge commits on the main branch -- at least with consent we can push a squash to the contributor's branch (assuming they left the checkbox checked when creating a PR that allows maintainers to push to their branch) |
@asottile how strong do you feel about others using a squash based work-flow (for both new contributors or own work-flows) personally i don't mind, as the content delivered is roughly the same, i only want the history control for myself for my own utility |
I'm fine with users personally using squash (I do myself) -- I don't want squash as a "merge strategy" as stated above |
I personally also don't mind enabling squash merging |
@nicoddemus @RonnyPfannschmidt (2 months have passed. Please either enable it finally, or close the issue) |
enabled |
I would really like to enable squash-merging via the GitHub UI.
This would allow to have something more meaningful instead of the following easily:
While you can rebase/squash things yourself and force-push, it will a) trigger an extra CI build and b) it cannot be done for other contributors PRs easily.
The text was updated successfully, but these errors were encountered: