push
Perform a push.
Perform all the steps for a push. If no refspecs are passed, then the configured refspecs will be used.
Signature
class Remote {
push(
refspecs: string[],
options?: PushOptions,
signal?: AbortSignal,
): Promise<void>;
}
Parameters
- refspecsrequired · string[]
Refspecs to push to remote.
- optionsnull | PushOptions
Options for push remote.
- credentialCredential
A interface to represent git credentials in libgit2.
- customHeadersstring[]
Set extra headers for this push operation.
- followRedirectsRemoteRedirect
Set remote redirection settings; whether redirects to another host are permitted. By default, git will follow a redirect on the initial request (
/info/refs
), but not subsequent requests.-
None
: Do not follow any off-site redirects at any stage of the fetch or push.
-Initial
: Allow off-site redirects only upon the initial request. This is the default.
-All
: Allow redirects at any stage in the fetch or push. - pbParallelismnumber
If the transport being used to push to the remote requires the creation of a pack file, this controls the number of worker threads used by the packbuilder when creating that pack file to be sent to the remote. If set to 0, the packbuilder will auto-detect the number of threads to create, and the default value is 1.
- proxyProxyOptions
Set the proxy options to use for the push operation.
- autoboolean
Try to auto-detect the proxy from the git configuration. Note that this will override
url
specified before. - urlstring
Specify the exact URL of the proxy to use. Note that this will override
auto
specified before.
- autoboolean
- remoteOptionsstring[]
Set "push options" to deliver to the remote.
- credentialCredential
- signalnull | AbortSignal
Abort signal.
Examples
import { openRepository } from 'es-git';
const repo = await openRepository('/path/to/repo');
const remote = repo.getRemote('origin');
// Push the local "main" branch to the remote "other" branch
await remote.push(['refs/heads/main:refs/heads/other']);
// Push with credential.
await remote.push(['refs/heads/main:refs/heads/other'], {
credential: {
type: 'Plain',
password: '<personal access token>',
},
});