DEV Community

Discussion on: Learn git concepts, not commands

Collapse
 
parkerholladay profile image
Parker Holladay

Great write up on crucial concepts to understanding how/why to use various git commands. There is one semantic distinction that I find helpful when talking about rebase to those unfamiliar with it. Rather than saying:

We re-base our add_patrick branch on the current state of the master branch.

It might be clearer what is happening if you say:

We re-base our add_patrick branch from the current state of the master branch.

That is to say, we get a new base set of commits for our branch from another branch. So, as you describe, when we run the command git rebase master [add_patrick], we are taking all commits from master that add_patrick does not yet have, and rewinding to apply them to HEAD before replaying our commits in add_patrick.

Collapse
 
naurel1467 profile image
Naurel1467

Now i get it...thanx

Collapse
 
unseenwizzard profile image
Nico Riedmann

For me personally understanding the on or onto wording for rebase as it's also used in the git reference actually helped me when I learned about it originally.

I take my changes, which where originally based on some branch HEAD, and I put them onto some other branch's current state (or state of the same branch)

Collapse
 
parkerholladay profile image
Parker Holladay

Like I said, it is semantics, but I've found that slight change in wording useful for some when helping them understand rebase.

Thread Thread
 
wobuyaotweet profile image
Not Real • Edited

Agreed - I completely misunderstood this at first because “rewind and rebase onto” sounds like “take my work from ‘add_patrick’, add all those commits “onto” ‘master’ (which doesn’t happen & wouldn’t really make sense) before moving the divergence point & continuing on the current branch.

The key point to understand is that you get all new commits from ‘master’ so your current branch is up to date with it (kinda like a git pull), then reapply the commits from ‘add_patrick’ again from that new point of divergence from master, but still on ‘add_patrick’ itself.

That confusion on my part aside, I found this to be a fantastic overview! Thanks!