git sync在VSCode中做了什么

时间:2016-04-27 00:47:42

标签: git visual-studio-code

在Visual Studio代码中同步更改时实际运行了哪些命令?

git sync in vscode

2 个答案:

答案 0 :(得分:17)

来自VSCode online help

  

鉴于您的存储库已连接到某个远程存储器并且已检出的分支具有到该远程分支的上游链接,VS Code为您提供推送,拉取和同步该分支的有用操作(后者将运行一个pull命令后跟一个push命令)。

看来,如果在给定分支上运行同步更改,它将执行以下操作:

git pull origin someBranch
git push origin someBranch

根据@FelikZ的评论,pull --rebase的一种方式是git pull的默认行为是通过添加以下内容来配置.gitconfig文件:

[pull]
    rebase = true

然后,当VSCode插件发出git pull时,它应该默认使用rebase策略。如果您按照上面的链接滚动到“Git patch / diff模式”部分,您将看到一个屏幕截图,它实际上显示了配置Git以通过rebase进行拉动。

更新:从v1.28开始,现在有一个git.rebaseWhenSync设置。来自release notes

  

git.rebaseWhenSync设置允许您将Sync命令配置为在运行时始终使用rebase而不是merge。

答案 1 :(得分:0)

Visual Studio代码同步序列:推+拉 screen shot from VS Code

Visual Studio 2019同步序列:拉+推 screen shoot from Visual Studio 2019 documentation