On the GIT tab in Visual Studio Code there is an context menu with these items:
==================
==================
...
What does the publish button do?
Allows you to choose which remote you want to push to.
A local branch that you create on your machine is kept private to you until you explicitly decide to publish it. This means that it's perfectly possible to keep some of your work private while sharing only certain other branches with the world.
If you want to push to, pull from, or synchronize using a branch you have created, you must publish the branch. You can still commit to an unpublished branch, but until you publish, you will not be able to send your commits to source control for backup.
Push from Visual Studio to a remote branch One of those improvements is the ability to push (also known as publishing) a local project straight to GitHub with a single click. The final stage in a simple Git workflow is to push changes to your remote. A remote is a safe place to store your code in the cloud.
After checking the source code of Visual Studio Code.
Push the current branch to the default remote upstream
public run(context?: any):Promise {
return this.gitService.push() // ... removed for brevity
}
There is UPSTREAM and recent push/pulls (ahead)
if (!HEAD || !HEAD.name || !HEAD.upstream) {
return false;
}
if (!HEAD.ahead) { // no commits to pull or push
return false;
}
Allows you to choose which remote you want to push to.
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 }))
}
There is NO UPSTREAM and off course remote branches are set.
if (model.getRemotes().length === 0) {
return false;
}
if (!HEAD || !HEAD.name || HEAD.upstream) {
return false;
}
From the docs:
If there is no upstream branch configured and the Git repository has remotes set up, the Publish action is enabled. This will let you publish the current branch to a remote.
So I'd expect that if you have an upstream branch configured, you would be able to Push (i.e. push directly to the configured upstream branch) and if you have no upstream branch configured you are only allowed to Publish (i.e. select a remote and branch to push at).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With