47

I suppose I'm getting confused about the wording within the Visual Studio 2019 Git Rebase UI. Silly question.

Scenario: I'm working in a branch called COREv2.0 . Bug fixes and other such things have been committed to master. COREv2.0 is still a work in progress, but I want to pull in those changes from master so I have those fixes that master has.

Thus, in my own words, I believe I want to rebase the COREv2.0 branch on the current master.

In Visual Studio, do I need to rebase FROM the current branch (COREv2.0) ONTO master? Or do I have that reversed? Does this screenshot represent what I'm wanting to do here?

enter image description here

3 Answers 3

48

In Visual Studio, do I need to rebase FROM the current branch (COREv2.0) ONTO master?

Yes.

One of the first rule of Git is that you can only change the branch you have checked out i.e. the "current branch".

(Side note: The reason is because a lot of git actions could end up with conflicts to solve by the user and in this case, you need to have a working directory to work into.)

The 'onto' branch is the one with which you want to sync with. With a feature branch, it's most of the time master that you want to rebase onto.. .

Does this screenshot represent what I'm wanting to do here?

Yes.

A picture could help understand : https://cms-assets.tutsplus.com/uploads/users/585/posts/23191/image/rebase.png

1
  • @Sabuncu I have not included it because it's an image I found in Internet (trying to find the more understandable one) and I don't know the license. So I don't think we have the right to include it...
    – Philippe
    May 18, 2022 at 18:03
20

Does this screenshot represent what I'm wanting to do here?

It's a little different in Visual Studio 2019. Here you can rebase branches in "Branches" pane of "Git Repository" tab, which is accessible from both View>Git Repository (Ctrl+0,Ctrl+R) or Git>Manage Branches menus.

To rebase your feature branch onto master:

  1. checkout feature branch
  2. in the list of branches in "Branches" pane, right-click on master
  3. find and click the Rebase '<feature-branch>' onto 'master' item in popup

This is equivalent to:

git rebase master <feature-branch>

or

git rebase master

, when the feature branch is checked out.

1
  • 2
    I find this answer better explained in terms of git commands.. thanks
    – Learner
    Feb 18, 2022 at 9:22
-2

I think you are looking for this command: git merge master. It will merge master branch into your checked-out branch ('COREv2.0').

1
  • 5
    A merge would bring all the history of master into the feature branch. A rebase would bring in the changes in master without the history of those changes, effectively moving the point at which the feature branch was created up to the present day. They say to only use rebase if you are the only one working on the feature branch. If so then I like this method over merge personally in the exact scenario of the OP. Apr 7, 2021 at 14:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.