doc: Explain squashing with merge commits #25165

pull MarcoFalke wants to merge 1 commits into bitcoin:master from MarcoFalke:2205-doc-squash-🐾 changing 1 files +6 −4
  1. MarcoFalke commented at 7:14 AM on May 18, 2022: member

    This avoids having to explain it in each thread

  2. MarcoFalke commented at 7:15 AM on May 18, 2022: member

    :rotating_light: Warning, this is untested, but tests and review are welcome.

  3. david-bakin commented at 7:27 AM on May 18, 2022: contributor

    What's wrong with a git merge --squash which I see is not recommended earlier in this document or in your update? (I really don't know, BTW, which is why I'm asking.)

  4. jonatack commented at 7:29 AM on May 18, 2022: member

    -0 on adding further git documentation to the repo, there are other and better resources

  5. jonatack commented at 7:31 AM on May 18, 2022: member

    This avoids having to explain it in each thread

    AFAICS you use pre-prepared maintainer responses and could add an appropriate link to an external resource where needed.

  6. in CONTRIBUTING.md:220 in faa280a9d8 outdated
     221 | -interface and ask for help in the pull request.
     222 | +If your change contain a merge commit, the above workflow may not work. You
     223 | +have the option to squash everything into *one* commit, or *keep* the commits
     224 | +in a non-interactive rebase.
     225 | +
     226 | +To squash everything into one commit.
    


    laanwj commented at 7:42 AM on May 18, 2022:

    I think keeping this part is enough. By far and wide, a new contributor will want to squash everything into one commit. Providing more options may just confuse them.


    MarcoFalke commented at 12:31 PM on May 18, 2022:

    Thx, fixed.

  7. laanwj commented at 7:44 AM on May 18, 2022: member

    Concept ACK. I think having some easy to follow steps here is useful. I do agree with @jonatack that going into too much details about git usage is out of scope.

  8. DrahtBot added the label Docs on May 18, 2022
  9. vincenzopalazzo approved
  10. MarcoFalke commented at 12:24 PM on May 18, 2022: member

    What's wrong with a git merge --squash which I see is not recommended earlier in this document or in your update? (I really don't know, BTW, which is why I'm asking.)

    For me, this does not work:

    $ git merge --squash bitcoin-core/master 
    Already up to date. (nothing to squash)
    
  11. MarcoFalke commented at 12:25 PM on May 18, 2022: member

    -0 on adding further git documentation to the repo, there are other and better resources

    I agree. Mind sharing a link to the "other and better resources" that can be used?

  12. MarcoFalke force-pushed on May 18, 2022
  13. MarcoFalke commented at 12:30 PM on May 18, 2022: member

    Recall that we are probably the only open source project that doesn't use the "squash on merge" GitHub feature, so I don't think there is documentation about this out there, but I am more than happy to be proven wrong.

  14. jonatack commented at 1:19 PM on May 18, 2022: member

    I agree. Mind sharing a link to the "other and better resources" that can be used?

    A prepared response may be a better place than the repo for an external link, but here are a couple that are similar to your method (rather than, say, the more flexible git rebase -i).

  15. MarcoFalke commented at 1:37 PM on May 18, 2022: member

    here are a couple that are similar to your method

    Yes, this is where I got the idea from. However, they rely on commit-counting, which is non-trivial with merge commits.

  16. MarcoFalke force-pushed on May 18, 2022
  17. MarcoFalke force-pushed on May 18, 2022
  18. MarcoFalke commented at 2:17 PM on May 18, 2022: member

    Changed to a more general approach (that may involve fixing conflicts again)

  19. suhailsaqan commented at 6:19 PM on May 18, 2022: contributor

    Changed to a more general approach (that may involve fixing conflicts again)

    That didn't work for my case in #25161 unfortunately.

  20. MarcoFalke commented at 7:47 PM on May 18, 2022: member

    Can you elaborate a bit on this? I tried it on #25161 and it worked for me.

  21. suhailsaqan commented at 8:18 PM on May 18, 2022: contributor

    I must have done something wrong then. I can't remember exactly what happened but I think I actually accidentally pulled and pushed after running git rebase FETCH_HEAD which messed it all up again so I had to do something longer to fix it. Sorry for the confusion.

  22. in CONTRIBUTING.md:223 in 888890302e outdated
     221 | -interface and ask for help in the pull request.
     222 | +If your change contains a merge commit, the above workflow may not work and you
     223 | +will need to remove the merge commit first.
     224 | +
     225 | +    git fetch https://github.com/bitcoin/bitcoin  # Fetch the latest upstream commit
     226 | +    git rebase FETCH_HEAD
    


    laanwj commented at 9:28 AM on May 20, 2022:

    Does a plain rebase work to remove merge commits? I always assumed it was much more hassle.


    MarcoFalke commented at 9:33 AM on May 20, 2022:

    Yeah, it should remove them. Obviously you'll have to solve the conflicts again (if there were any solved in the merge commit).

    Though I think this general approach should work in all possible cases regardless of how messed up the commit history is. Any other approach requires a bit more git knowledge, but there were complaints that we don't want to dive too deep in this document.


    MarcoFalke commented at 6:39 AM on May 24, 2022:

    Resolving as fixed?

  23. theStack commented at 10:11 AM on May 23, 2022: member

    If your change contains a merge commit...

    Very likely I'm missing something fundamental here, but why would a change in a PR ever contain a merge commit? Is this for the scenario of "PR foo is based on PR bar, PR bar has been merged, now PR foo needs to rebase?"

  24. MarcoFalke commented at 5:06 PM on May 23, 2022: member

    It usually happens when the author merges with current Bitcoin Core master instead of rebase.

  25. theStack approved
  26. theStack commented at 12:01 AM on May 24, 2022: member

    ACK 888890302edacf3392957ef9e682cd6cb17a5f5c

    Alternatively, could move the two git lines to the rebase section below (where currently concrete git instructions are missing, it only says that "git rebase" can be used, but without example) and link to there, e.g. "you will need to remove the merge commit first by rebasing on the target branch".

  27. doc: Explain squashing with merge commits fa2d226ac9
  28. MarcoFalke force-pushed on May 24, 2022
  29. MarcoFalke commented at 6:41 AM on May 24, 2022: member

    Thx, done.

  30. jonatack commented at 12:11 PM on May 24, 2022: member

    Aside, just came across https://github.com/lsilva01/operating-bitcoin-core-v1/blob/main/git-tutorial.md ... maybe reply to people with https://github.com/lsilva01/operating-bitcoin-core-v1/blob/main/git-tutorial.md#2-squashing-and-rebasing when useful. (I'm not sure how sustainable it is for a contributor to not become familiar with git rebase -i, and most of the better tutorials and blog posts when searching for "how to squash your commits" seem to cover that approach, so suggesting it may be helpful to people, I don't know.)

  31. MarcoFalke commented at 9:09 AM on May 25, 2022: member

    Yeah, I am happy to review a pull request that removes the sections in our readme and replaces them with a link. Or should I do it here?

  32. laanwj commented at 6:38 AM on June 1, 2022: member

    ACK fa2d226ac950d8b4f7e430732f13ad408c504745 IMO, this is an improvement. The high-level longer term discussion on the scope of our documentation can of course go on.

  33. laanwj merged this on Jun 1, 2022
  34. laanwj closed this on Jun 1, 2022

  35. MarcoFalke deleted the branch on Jun 1, 2022
  36. sidhujag referenced this in commit c0af7ba9ca on Jun 1, 2022
  37. DrahtBot locked this on Jun 1, 2023

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me