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.11k stars 5.72k forks source link

Git merge unclear #1063

Open sant3e opened 1 year ago

sant3e commented 1 year ago

I apologize for creating this issue here, but could not find any Contact

I struggle with the Git Merge lesson. The interactive exercise was clear enough (goal and steps), but the actual lesson was not clear enough (to me) After the initial git merge bugFix we see that main has a new commit (C4) that stems from C2 and C3. The HEAD is also attached to main (the image has different colors for C0, C1, C2 and C3, C4) It was clear up to this point that this is what we must do to merge bugFix into main. This is also consistent with the interactive exercise

But ... now comes some further insights: git checkout bugFix; git merge main; ... which starts to explain something about the colors of the branches. Here is where you lost me completely.

What i got from this:

As the interactive exercise has only git merge bugFix (and not git merge main also) i do not understand what was supposed to happen here

FaithfulDev commented 3 months ago

I think what the lesson is trying to show, is that "git merge" always merges into the current branch.

image

Since before we had "main" checked out, we need to do a "git checkout bugfix" to change that.

Before we merged bugfix into main, we are now merging main into bugfix (the newly checked out branch). Why is everything the same color? In the previous step, we merged information stored on the bugfix branch, giving "main" all the information in bugfix. Now we merge main into bugfix, merging the information (the commit) that was parallel in main, into the bugfix branch. The "cursor" moves forward, since both main and bugfix now have the same history (you can reach every commit from the cursor point).

The question is: How could this be better communicated?

I think the lesson should be more direct in saying that "git merge bugfix" means "merge bugfix into the currently checked-out branch".

@sant3e Do you think that would help in the lesson?

psawa commented 2 months ago

I had the exact same thought, and glad to see that i'm not the only one! The color thing has really got me wondering what I was missing.