git sync 在 VSCode 中有什么作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36878344/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 11:59:01  来源:igfitidea点击:

What does git sync do in VSCode

gitvisual-studio-code

提问by Jay Wick

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

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

git sync in vscode

vscode中的git同步

采纳答案by Tim Biegeleisen

From the VSCode online help:

VSCode 在线帮助

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).

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

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 --rebasethe default behavior for git pullwould be to configure your .gitconfigfile by adding the following:

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

[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.

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

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

更新:从 v1.28 开始,现在有一个git.rebaseWhenSync设置。从发行说明

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

git.rebaseWhenSync 设置将让您配置 Sync 命令以在运行时始终使用 rebase 而不是合并。

回答by Armando Pitotti

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

Visual Studio Code 同步序列:来自 VS Code 的PUSH + PULL 屏幕截图

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

Visual Studio 2019 同步序列:来自 Visual Studio 2019 文档的PULL + PUSH 屏幕截图