gitbutler icon indicating copy to clipboard operation
gitbutler copied to clipboard

Gitbutler makes pointless rebase/merge for PRs

Open p1k0chu opened this issue 9 months ago • 1 comments

Version

0.14.14

Operating System

Linux

Distribution Method

AppImage (Linux)

Describe the issue

Every time i apply a pr branch gitbutler rebases it for no reason (requires force push now)

or if i disable force pushes it merges the master into pr branch, even if pr is up to date. (merge commit IS empty)

How to reproduce (Optional)

  1. open a local repo in gitbutler, that you didn't use gitbutler yet
  2. apply a pr branch

Expected behavior (Optional)

Not rebasing so i dont have to force push for no reason

Relevant log output (Optional)


p1k0chu avatar Apr 07 '25 17:04 p1k0chu

Thanks a lot for reporting, and sorry for the hassle.

Git commit-graphs can be very complex and right now I don't think the analysis of what to do is always correct. It's definitely on our list of things to address, but it can only happen incrementally, unfortunately.

Byron avatar Apr 08 '25 16:04 Byron

What is the status on this? (still happens on v0.15.2) From what I can see, this issue always happens even on simple use cases, such as applying a branch that can be fastforwarded onto an empty workspace.

hey2022 avatar Jul 14 '25 16:07 hey2022

The branch-application logic is scheduled for a complete rewrite, and we will move away from the rebase-by-default policy entirely.

It's still a little while out, but I'd expect these features to trickle in faster once our new technological foundation is in place.

Byron avatar Jul 15 '25 02:07 Byron

As the following PR https://github.com/gitbutlerapp/gitbutler/pull/9710 will close the issue where I left more details about the pointless rebases and then in turn needed force pushes. I will link it here for reference and so it does not get lost: https://github.com/gitbutlerapp/gitbutler/issues/2847#issuecomment-3148533731.

Copy paste out of that issue:

Integrate Upstream (yellow button)

  • It appears on each branch individually as soon as there are changes - checked every minute (with a setting check interval) or after a manual check (like it is now).
  • It should also appear on PR branches. Currently, if a PR is applied from a remote (not on the origin) and there is a push/ new change in the PR, the change is only reflected if I hit Unapply Stack and then delete the local branch and then reapply the PR branch. Related to: https://github.com/gitbutlerapp/gitbutler/issues/9664
  • When I click Integrate Upstream it should directly integrate the commits into the branch and that’s it -> no merge commit (not always possible), no push and certainly no force push needed.
    • At the moment, when I integrate upstream sometimes some commits get marked. And then these marked commits have to be force-pushed. This should be eliminated, as this issue prevents me from using GB when I work with others on the same branch as we disabled force-push on GitHub itself. The commits should just be pulled down and that is it. --> normally we should not need any merge commit or push at all to get change into the local branch
    • If there are local changes on the branch that are not pushed yet these changes could be stashed automatically temporarily until the changes are pulled and then restored right after. --> normally we should not need any merge commit or push at all to get change into the local branch
    • If there are changes commit but not yet pushed we probably need to do a merge commit of remote branch into local branch and then a normal push. --> Normal push no force push and only when there are local commits.
    • If I disable force push in setting at the moment I always need a merge commit which also should not be the case in my opinion. Also the merge commit that is done now is extremely wired and confused history a lot and adds not 1 but multiple additional commits that should not be committed again.

Cyan button (upstream)

The button now with v0.15.8 is actually pretty good. The only issue I have is the following:

  • When I choose Merge Upstream into next or any other feature branch I’m working on I choose merge not because it’s pretty (it isn’t) but because merging upstream (which can also be done in the GitHub UI when looking at a PR for example) does not require me to force-push afterward. Unfortunately, this is not the case with GB, as even with merge from upstream I need to force-push my changes. This should not be the case --> If I merge my upstream changes via merge no force push should be required just a normal push should be enough, like if I merge upstream in the GitHub PR UI.
  • Small improvement: If I disable force-pushing in settings, the rebase option should be disabled since rebasing is not possible without force-pushing as far as I know.

More issues with force push

  • There is another issue when adding a new branch to the workspace. Often a zero changes merge commit is created and that commit has to be force pushed - if that commit needs to be there for some reason it would be great if we could just push it. Perhaps this cannot be done any other way but this is problematic because force pushing is disabled on most of my repos so I want to avoid it if possible. Image

peaklabs-dev avatar Aug 06 '25 00:08 peaklabs-dev

Thanks for sharing your analysis and engagement with the topic, it's much appreciated!

Just as a note, I recommend to ensure that the "New workspace backend" is turned on as it effectively controls the yellow button. It does not yet control what happens when the button is pressed though, which is expected to not be what we want ATM.

Image

Byron avatar Aug 06 '25 02:08 Byron