Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git rebase using sourcetree

I think I am confused on how to use SourceTree GUI to do git rebase. I have two branches "master" and "dev". As seen, the two branch diverged. I want to do a rebase on "dev" branch, using command line, this would be:

git checkout dev git rebase master 

enter image description here

I would have expected to right click "dev", and choose "Rebase current changes onto dev". I assume current changes means "new commits on master". But picking this option seems have no effect whatsoever. What would be the correct steps?

like image 707
python152 Avatar asked Oct 08 '16 02:10

python152


People also ask

How do I rebase in SourceTree?

There are two ways to start an interactive rebase in Sourcetree. The first is to right-click (or context-click) on a commit and choose Rebase children of <sha> interactively. The second is to pull down the Repository menu and select Interactive rebase.

What does rebase mean in SourceTree?

So merging keeps the separate lines of development explicitly, while rebasing always ends up with a single linear path of development for both branches. But this rebase requires the commits on the source branch to be re-written, which changes their content and their SHAs.

How do you rebase and commit squash in SourceTree?

Right-click on the parent commit and select 'Rebase children of <sha> interactively'. After that, you'll be able to drag and drop to squash commits.


1 Answers

But picking this option seems have no effect whatsoever.

Yes, because current changes are the one of the current branches, which is dev.

Rebasing dev on top of dev means an no-op.

git checkout dev git rebase master 

That means: current branch is dev: to be rebased on top of master.

So in SourceTree, you need to right-click on master (while dev is checked out), and select:

Rebase current changes onto master 

Howe adds in the comments:

Current Naming of "rebase current changes onto [branch]" is misleading. Check out this improvement discussion SRCTREE-1578.

After finding myself baffled attempting to bring a feature branch up to date with development and failing, I've come to realize that the left-pane context menu item labeled “rebase current changes onto $somebranch” actually does the opposite of what its name suggests:
it rebases the current branch to the state of $somebranch;
In other words it rebases $somebranch onto (or into) the current branch, not the other way around. (Right?)

The preposition “onto” in the current text is misleading; it implies that the object of the sentence ($somebranch in my example) will receive the changes.
In fact, it is the opposite that will occur.
The absence of the current branch's name adds to the confusion.

A re-wording that improves the sentence structure and includes the name of the affected branch would afford a huge win for clarity.
For example:

rebase $currentbranch to head of $somebranch rebase $somebranch onto $currentbranch 
like image 170
VonC Avatar answered Sep 18 '22 12:09

VonC