25

Using built in Git in Visual Studio Code, I do not see a way to pull a specified remote branch into my current branch. Can I do this?

Example: I am working on branch myBranch and changes were merged into master on the remote. I want to pull the changes from master into my current myBranch

Gama11
  • 31,714
  • 9
  • 78
  • 100
stephen776
  • 9,134
  • 15
  • 74
  • 123

3 Answers3

19

I am using Version 1.30.1 (1.30.1) and now it has build-in way to do this.

enter image description here

Yang Wang
  • 580
  • 4
  • 14
  • 3
    one step that wasn't so clear to me was you needed to drill down to get to the branches. So after choosing Pull, Push then choosing Pull from..., you need to choose "origin" then your branches would appear. – sigmapi13 Feb 24 '21 at 21:51
  • Does this not pull that remote branch into whatever branch you are currently on locally? Or does it checkout to this as a new branch locally too? – Zaffer Jul 11 '21 at 12:04
  • There are no settings for this that I can find so this is all you get: The current working branch is where it pulls to, it doesn't have an option to select where to pull to, only where to pull from. **Before you pull** check your active branch in cs code, thats where the pull is going to. It doesnt give a warning or a confirmation. – CodingInTheUK Aug 07 '21 at 00:24
  • No longer the best answer. Basically VS isn't fetching remotes and the answer below shows you how to enable that by default. The other way is to just manually fetch all remotes... but you don't need to do that in full Visual Studio so its was a bit confusing for me – Piotr Kula Mar 16 '23 at 10:54
  • I had to do "Fetch from all remotes" to get the branch to show up to then pull. – cyberwombat Aug 16 '23 at 21:41
10

Finally i solve it this way

File->Preferences->Settings->User (Tab)-> Extentions ->git-> Autofeatch(set checkbox to true)

enter image description here

Now you will able to see remote branches in source control branches options

Moumit
  • 8,314
  • 9
  • 55
  • 59
  • 1
    This should be the accepted answer. ✔✅ Also, why is this not default. It in in full Visual Studio. Thank you so much for this! – Piotr Kula Mar 16 '23 at 10:53
8

I don't think there's currently a built-in way to do this, but I've found an extension for it: Git: Pull - Remote/Branch Specified

It adds a command with the same name, which when invoked, prompts you for the name of the remote and remote branch to pull from:

Gama11
  • 31,714
  • 9
  • 78
  • 100