GitHub squash-merge-based workflow #4328
-
I've been using jj for a few weeks on a project that is hosted on GitHub and for which the rest of the team is still using git. The project uses short-lived feature branches, GitHub PRs, and prefers squash merges onto the main branch. I'm now just in the middle of my first experience where I have a somewhat large feature that I've decided to split into 5 PRs, each based on the previous. These each correspond to a jj revision that represent some internally consistent change to the code. Having just squash merged the first of these PRs, I find I don't know how to reconcile jj to the new state. The first thing I don't know what to do with is that
If I try to operate on xrq then I am told:
I guess that's what the red and Why does xrq now resolve to more than one revision?
I see that I can abandon 061 but then the whole revision is gone from my history. Is there a good jj-based workflow for this git/GitHub workflow? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
Do you know how you ended up with that divergent change? I don't think that should happen by fetching from the server after your PR was squashed. It typically happens if you perform some operation on a commit that's already been rewritten. You should be able to figure out which operation it was by running The usual effect of squash merging is that jj has no way of knowing the relationship between the new upstream commit and your local commit it was created from. If you rebase your local commits onto the updated upstream main branch, it would typically result in the first commit in your chain becoming empty. You would then have to manually abandon it unless you ran |
Beta Was this translation helpful? Give feedback.
-
I have a conjecture about this, which I haven’t tested. Usually, once a feature has been merged, the branch is deleted as well. However, from this:
I understand that the remote branch was not deleted on Github, but was rather updated to point to the upstream commit instead. If I remember correctly how Github’s squash merge works, then the upstream commit’s diff is identical but the commit message differs slightly. Since the remote branch is still tracked by jj locally, it tries to update As for this:
Again, an untested conjecture. I suppose the new commit |
Beta Was this translation helpful? Give feedback.
-
I hit the same thing. In my case the divergence apparently started at a rebase operation:
and it was in relation to this merged commit: insanum/gcalcli@9444589 In this case it was a merge commit, not a squash, but I believe there might've been a rebase or something in GitHub behind the scenes because I was working with several PRs that might've had a base older than master HEAD at the time I merged them. Before that operation, my repo state was something like: $ jj log --at-op=ae4eca729a39
@ xpmsqozp [email protected] b7097181
├─┬─┬─╮ (empty) (no description set)
│ │ ○ │ pnvkvtqk [email protected] auth_setup* ad8646d1
│ │ ├─╯ Improve auth setup experience with more self-contained explanations/links
│ ○ │ llllmwor [email protected] argcomplete* 0773d598
│ ├─╯ feat: Support shell completion using argcomplete
○ │ lxnkwmwm [email protected] tooling* HEAD@git 49b8589e
├─╯ tooling: drop flake8, configure ruff
○ lvluvxmp [email protected] add_endflag?? master* 8a251991
├─╮ (empty) Merge pull request #708 from insanum/add_endflag
│ │ ◆ lvluvxmp hidden [email protected] master@origin 94445895
├───╯ (empty) Merge pull request #708 from insanum/add_endflag
◆ │ ttyuwytk [email protected] af1c1f3d
├─╮ (empty) Merge pull request #709 from insanum/stubs and then I tried to rebase everything onto the merged master version of that add_endflag branch and things got weird. |
Beta Was this translation helpful? Give feedback.
Ah, I think I see what's going on then. I'm guessing your scenario was something like this: