gitbutler icon indicating copy to clipboard operation
gitbutler copied to clipboard

Remote commits are not pulled, causing the danger of overwriting them with local commits

Open gtupak opened this issue 1 year ago • 3 comments

There is currently a way to overwrite the remote commits without knowing.

To repro:

  1. Ensure "Allow force pushing" is not selected in the GitButler's project settings
  2. Make a new virtual branch
  3. Make a commit test 1, push the branch and make a PR
  4. In Github, open the PR and edit a file on the branch, and commit it with test 2
  5. Make a commit locally and call it test 3.
  6. Force push the changes - even though "allow force pushing" is not enabled.
  7. Notice that the test 2 commit was overwritten.

This is quite dangerous in a situation where you contribute with other developers on the same branch as you can easily overwrite their work without knowing.

This issue is the result of this thread on Discord.

gtupak avatar Feb 20 '24 22:02 gtupak

I think this is an even broader problem which is a deal breaker when using the tool: the inability of merging remote changes to the matching virtual branch. This happens all the time when there are at least 2 developers working on the same feature branch :/

gtupak avatar Feb 21 '24 06:02 gtupak

☝🏼 I have been wondering about this myself. :) From reading the documentation the expected workflow in this case would be to create a new "trunk" branch which is the "base branch" shared with other developers and then use PRs against this base branch. This should work fine, but it is somewhat an hassle not being able to use pull the changes in any way, but at the same time I understand that this would be problematic to integrate, because then you are updating only the "virtual branch" instead of the "base".

I hope my understanding&explanation is correct and makes sense. 😅

esolitos avatar Feb 21 '24 07:02 esolitos

We're making some progress e.g. here, but it's hidden since we need to refactor the Rust code that is meant to merge in upstream changes.

Once we have this working again we can build a --force-with-lease like flag to prevent accidentally overwriting commits pushed by others!

mtsgrd avatar Feb 21 '24 21:02 mtsgrd