Stuck trying to implement a GitHub-based branch workflow #3165
-
Hi all, After working with jj for a few weeks without branches on single user repos (which is a breeze!), I am now trying to implement a GitHub-based team workflow – but to be honest: I’m stuck. What I’m trying to do is to either merge or (preferably) squash the two branches into main:
Trying a merge workflowTest 1
It seems as if the first merge has disappeared from main. Test 2
Again, I tried to merge two branches into main, but either both ( Rebase workflow
No rebase seems to have happened. Sorry, guys. I do know that this is jj’s expected behavior. But how do I a) merge or b) rebase two branches into main? Or is there any branch-less workflow you can use with GitHub? Unless I have missed something, there are no instructions on how these two typical GitHub-based workflows work with jj. Thanks for your help. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
To give an immediate answer your question using the merge workflow: jj new o w r
jj describe -m 'merge: add-a-files and add-b-files to master'
jj new # create a new working copy on top of the merge commit This will result in a graph that looks like this, assuming the base is
So, the resulting merge commit The last two commands can be shortened thanks to jj new o w r
jj commit -m 'merge: add-a-files and add-b-files to master' This graph is what you want from the examples. Now to focus on specific examples and why they didn't do that: Merge Test 1: accidentally creating different mergesLet's rewrite your example to use the names of the nodes above: jj new X A1 # results in M1
jj commit -m "merge 1"
jj new X A2 # results in M2
jj commit -m "merge 2" The result of this example is two different merge commits entirely. In short, it makes your graph look like this:
The second command should NOT use the base jj new X A2 # results in M1
jj new M1 B2 # results in another merge with M1 as a parent
jj new # create a new working copy, leaving the merge commit The resulting graph of these commands would be the following "criss-cross" merge:
Merge Test 2:
|
Beta Was this translation helpful? Give feedback.
-
Thank you very, very much, @thoughtpolice! I really appreciate your detailed answers. When I saw the scope of your reply, I thought I would have to read the answers quite a few times. But your explanations are so precise that one can get it straight away. Your graphs make everything super clear and are a great reference. (Something like this would be an excellent addition to the official documentation, especially for onboarding.) Your “bonus section” about
That’s what I thought and what I favor. All I want is to be prepared to deal with pull requests ;-) For my stuff I don’t use branches at all.
Yes, it requires to rethink. I cannot judge whether a change here is necessary (I will the discussion about this), but again: Your graphs make this immediately understandable.
Just a bit. I don’t exactly know why, but conflicts were a lot easier to resolve than in git.
You wouldn’t believe how much! I really got it. Thank you very much for your time, your efforts and your patience. |
Beta Was this translation helpful? Give feedback.
To give an immediate answer your question using the merge workflow:
jj new
can create a merge with any number of parents. So you don't need to do two merges, unless you want to. Instead, you can run this, assuming your original commit graph is what things look like:This will result in a graph that looks like this, assuming the base is
X
, and the merge commit commit isM
So, the resulting merge commit
M
has 3 parent commits:…