learnGitBranching icon indicating copy to clipboard operation
learnGitBranching copied to clipboard

Wrong solution in level "Rebasing over 9000 times"

Open Afelium04 opened this issue 1 year ago • 2 comments

Hello, I found your tool really useful so far, but I suspect there may be an error within the solution for the level named "Rebasing over 9000 times": image

I tried to recreate the same tree in git:

git commit --allow-empty -m C0

git checkout -b side
git commit --allow-empty -m C4
git commit --allow-empty -m C5

git checkout -b another
git commit --allow-empty -m C7

git checkout side
git commit --allow-empty -m C6

git checkout main
git commit --allow-empty -m C1

git checkout -b bugFix
git commit --allow-empty -m C3

git checkout main
git commit --allow-empty -m C2

(made commits in this order so that the git graph comes out similar to the image, please tell me if there's an easier way to change the order the branches are displayed)

then applied the proposed solution:

git rebase main bugFix
git rebase bugFix side
git rebase side another
git rebase another main

but got a different result: image (when rebasing another onto side, nodes C4 and C5 are appended a second time).

Afelium04 avatar Dec 25 '24 12:12 Afelium04

I think this actually depends on the version of git you're running -- this project is over a decade old so it matches the git semantics of way back then, not the modern version unfortunately.

What version are you running locally?

Anyways this project is more about learning the concepts that enable you to work in git, so hopefully a few differences are tolerable :)

pcottle avatar Dec 25 '24 21:12 pcottle

Hi, I'm currently running Git version 2.40.0.

I understand that the aim of the project is just to give an introduction to basic git commands, but I believe the inconsistency may lie within the project itself; the earlier level "rebase introduction" stated that:

Rebasing essentially takes a set of commits, "copies" them, and plops them down somewhere else

There! Since main was an ancestor of bugFix, git simply moved the main branch reference forward in history.

My takeaway from these statements was that rebase takes all commits of the current branch up to its common ancestor with the destination branch (which contradicts the proposed solution and matches the behaviour on my machine).

Afelium04 avatar Dec 29 '24 10:12 Afelium04