Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: Rebase Terminology

Tags:

git

Given the following branches

     A---B---C topic (HEAD)
    /
D---E---F---G master

and running the command

git rebase master

Does that mean, that we are

  • rebasing topic/HEAD on master, or...
  • rebasing master with topic/HEAD?

I can't infer how I would express this action in a sentence from the git-rebase man pages.

PS: I know what rebase is and what it does, I just want to know "how to speak" the command, since the first argument is actually called upstream.

like image 577
Era Avatar asked Apr 22 '19 20:04

Era


2 Answers

The resultant branch layout would be as follows:

      A---B---C ("dangling", waiting for garbage collection)
     /
D---E---F---G---A'---B'---C' < topic (HEAD)
            ^
          master

You would be rebasing your topic (current) branch with master, thus changing the ancestry of A (now A' since it's not quite the same commit) from E to G.

like image 136
Makoto Avatar answered Oct 20 '22 23:10

Makoto


The first, rebasing topic/HEAD on master.

You're taking all the commits up to and including the latest of master. The current state/the latest commit of master is now again the 'base' on which you based your work.

You rebased that work on (the work already done in) master.

And (copies of) your commits will be added at the end, after the last commit in master. Credits to Makoto for supplying the graphic that explains the above.

For more reference materials, I personally think this tutorial by Atlassian explains it really nicely, including similar graphics. The basic rebasing is a 2 minute read, after which it continues with interactive rebasing, which is a really, really nice feature to have in your toolkit!

like image 43
GolezTrol Avatar answered Oct 20 '22 22:10

GolezTrol