在 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/