pcottle / learnGitBranching

An interactive git visualization and tutorial. Aspiring students of git can use this app to educate and challenge themselves towards mastery of git!
https://pcottle.github.io/learnGitBranching/
MIT License
30.61k stars 5.75k forks source link

Levels building: how to create remote tree? #1008

Closed OnkelTem closed 2 years ago

OnkelTem commented 2 years ago

Hi!

I'm struggling to create my first level by emulating a typical situation we face in our work. However, I immediately stumbled upon the inability to build the remote tree I want. The only command I have so far is git fakeTeamwork which just creates a commit, but doesn't do any merges, rebases, etc.

For example, in a simplest case, the remote may look like:

C0 -> C1 -> C2 -> C4 (feature1, main)

While the local may contain:

C0 -> C1 (main, o/main) -> C3 -> C5 (feature2)

How to create this?

pcottle commented 2 years ago

Yeah it's tricky since you can't do the full range of commands for the remote. A way to get around this is to make the tree you want locally, then clone, and then try to delete state backwards to something that resembles your problem.

Here is the closest I could get: https://learngitbranching.js.org/?NODEMO&command=git%20checkout%20-b%20feature1;%20gc;%20gc;%20git%20checkout%20main;%20git%20rebase%20feature1;%20git%20clone;%20git%20checkout%20C1;%20git%20checkout%20-b%20feature2;%20gc;%20gc;git%20branch%20-f%20main%20C1;%20git%20branch%20-d%20feature1;

Screen Shot 2022-09-04 at 9 40 01 AM
OnkelTem commented 2 years ago

@pcottle Thanks Peter! So you've initialized the remote from local, not cleaning up this part (C2 and C3), and now the local tree is in the state as if git fetch was already executed. Is there maybe another way, like creating a JSON with a snapshot of the remote party? And how did you get that long URL? Is there a share link/button in the UI?

pcottle commented 2 years ago

Is there maybe another way, like creating a JSON with a snapshot of the remote party?

there is a "load tree now" that can import an arbitrary string but its difficult to get those strings correct :P

And how did you get that long URL? Is there a share link/button in the UI?

nope I just know its a url param we look at. probably should encourage someone to build share button functionality...