Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does git sync do in VSCode

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

git sync in vscode

like image 565
Jay Wick Avatar asked Apr 27 '16 00:04

Jay Wick


People also ask

What is the use of Git sync?

git-sync is a simple command that pulls a git repository into a local directory. It is a perfect "sidecar" container in Kubernetes - it can periodically pull files down from a repository so that an application can consume them. git-sync can pull one time, or on a regular interval.

What is git sync vs pull?

Git pull is a git fetch followed by git merge - read here. Git fetch fetches info about remote repositories - read here. Git sync does everything in one command meaning pull and push read here.

What is commit and sync in git?

Commit All and Sync: saves changes to local repository, pulls changes from the remote to sync with local changes, and then pushes changes to the remote repository.


2 Answers

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.

like image 132
Tim Biegeleisen Avatar answered Oct 21 '22 02:10

Tim Biegeleisen


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

like image 4
Armando Pitotti Avatar answered Oct 21 '22 02:10

Armando Pitotti