51

What commands are actually run when you Synchronise Changes in Visual Studio Code?

git sync in vscode

Jay Wick
  • 12,325
  • 10
  • 54
  • 78

2 Answers2

47

From the VSCode online help:

Given that your repository is connected to some remote and that your checked out branch has an upstream link to a branch in that remote, VS Code offers you useful actions to push, pull and sync that branch (the latter will run a pull command followed by a push command).

It appears that if you run synchronize changes on a given branch, it will do the following:

git pull origin someBranch
git push origin someBranch

Per the comment by @FelikZ one way to make pull --rebase the default behavior for git pull would be to configure your .gitconfig file by adding the following:

[pull]
    rebase = true

Then, when the VSCode plugin issues a git pull, it should use the rebase strategy by default. If you follow the above link and scroll to the section "Git patch/diff mode," you will see a screen capture which actually shows configuring Git for pulling via rebase.

Update: As of v1.28 there is now a git.rebaseWhenSync setting. From the release notes:

The git.rebaseWhenSync setting will let you configure the Sync command to always use rebase instead of merge when running.

Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
  • I could have sworn there was more to it, such as stashing pending changes before pushing :) – Jay Wick Apr 27 '16 at 03:39
  • Is there a way to change it behaviour, so it will `pull --rebase` instead of just pull? – FelikZ Nov 15 '17 at 13:01
  • 2
    @FelikZ I updated my answer. I think you can update your `.gitconfig` file to use rebase by default when pulling. – Tim Biegeleisen Nov 15 '17 at 13:48
  • 1
    @TimBiegeleisen thanks for a response. I did some search and have found, that its actually will be released in VSCode itself soon (November 2017), [see this](https://github.com/Microsoft/vscode/pull/31416) ! – FelikZ Nov 15 '17 at 14:06
  • 1
    Updated answer to include new `git.rebaseWhenSync` setting! – Jay Wick Oct 08 '18 at 21:53
  • If you want to do this on all branches, you can grab [hub](https://hub.github.com/) and run `hub sync` (or `alias git="hub"` in your `.bash_profile` or `.zshrc` to run `git sync`) – Leo Aug 20 '19 at 14:48
4

Visual Studio Code sync sequence : PUSH + PULL screen shot from VS Code

Visual Studio 2019 sync sequence : PULL + PUSH screen shoot from Visual Studio 2019 documentation