git - VS代码: What is the difference between push and publish

标签 git visual-studio-code

在 Visual Studio Code 的 GIT 选项卡上有一个包含以下项目的上下文菜单:

  • 同步
  • pull
  • pull (释放)
  • 推送

==================

  • 发布

==================

...

发布按钮有什么作用?

最佳答案

检查了Visual Studio Code的源代码后。

推送

当前分支推送到默认远程上游

public run(context?: any):Promise {
    return this.gitService.push() // ... removed for brevity        
}

激活时间:

UPSTREAM和最近的推/pull (领先)

if (!HEAD || !HEAD.name || !HEAD.upstream) {
    return false;
}

if (!HEAD.ahead) { // no commits to pull or push
    return false;
}

发布

允许您选择要推送到的 Remote 。

public run(context?: any):Promise {
        const model = this.gitService.getModel();
        const remotes = model.getRemotes();
        const branchName = model.getHEAD().name;
        let promise: TPromise<string>;

        if (remotes.length === 1) {
            const remoteName = remotes[0].name;
            promise = TPromise.as(result ? remoteName : null);
        } else {
            // open the option picker            
            promise = this.quickOpenService.pick(picks, { placeHolder })
                .then(pick => pick && pick.label);
        }

        return promise
            .then(remote => remote && this.gitService.push(remote, branchName, { setUpstream: true }))            
}

激活时

没有没有上游并且当然设置了远程分支。

if (model.getRemotes().length === 0) {
    return false;
}

if (!HEAD || !HEAD.name || HEAD.upstream) {
    return false;
}

关于git - VS代码: What is the difference between push and publish,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37075486/

相关文章:

visual-studio-code - VSCode 仅针对打开的文件显示 TSLint 错误

visual-studio-code - 无法在 VSCode ROS 调试器中读取环境变量 $HOME

git - Maven 版本 :prepare fails to commit tag

windows - git - 双启动 ubuntu 和 windows,带有单独的数据分区

git 只获取最后的列表,即 2 次提交

macos - 如何强制 Git 使用封闭文件夹的所有者和权限?

file - 如何在 Visual Studio Code 中查看本地历史记录更改?

typescript - Visual Studio Code : official TypeScript extension?

visual-studio-code - 将自定义自动导入添加到 vscode

git push -u origin master 致命: unable to update url base from redirection: