How do I merge current master branch into my branch visual studio/azure devops?

Viewed 3833

So I have the master branch, and another branch, lets call it 'branch2', that I am working on that is based off of the master branch. There are important changes in the current master branch that were made from someone else that I need to merge into branch2. Just wondering how to do this within visual studio or azure devops.

2 Answers

In VS,

  1. open the git pane.
  2. View the branches sub-pane.
  3. Expand the'origin' branch
  4. right click the master branch (under origin)
  5. select merge master branch in origin\branch 2
  6. under local branches right branch 2 pull latest
  7. done

Download gitbash for windows, or install git on linux. I recommend command line rather than trying to use the VS or DevOps GUI. I prefer command line simply because I have better control over my commands and are less likely to mess things up. When things do get messed up, I can review the commands I used that led me there. Be sure to be in the root folder of your git repo when you use the commands. These are the three commands you would use:

git checkout branch2
git fetch
git pull origin master

What this is doing, you want to be in your feature branch, "Branch 2". Then you do a fetch, which pulls changes down from the server but doesn't apply them. Then when you pull origin master, you are pulling the master branch changes into your current branch.

Related