---
layout: default
menu_item: api
title: Remote
description: Version 0.24.0
menu_item: api
return_to:
"API Documentation Index": /api/
sections:
"addFetch": "#addFetch"
"addPush": "#addPush"
"create": "#create"
"createAnonymous": "#createAnonymous"
"createDetached": "#createDetached"
"createWithFetchspec": "#createWithFetchspec"
"delete": "#delete"
"isValidName": "#isValidName"
"list": "#list"
"lookup": "#lookup"
"setAutotag": "#setAutotag"
"setPushurl": "#setPushurl"
"setUrl": "#setUrl"
"#autotag": "#autotag"
"#connect": "#connect"
"#connected": "#connected"
"#defaultBranch": "#defaultBranch"
"#disconnect": "#disconnect"
"#download": "#download"
"#dup": "#dup"
"#fetch": "#fetch"
"#getFetchRefspecs": "#getFetchRefspecs"
"#getPushRefspecs": "#getPushRefspecs"
"#getRefspec": "#getRefspec"
"#name": "#name"
"#owner": "#owner"
"#prune": "#prune"
"#pruneRefs": "#pruneRefs"
"#push": "#push"
"#pushurl": "#pushurl"
"#referenceList": "#referenceList"
"#refspecCount": "#refspecCount"
"#stats": "#stats"
"#stop": "#stop"
"#updateTips": "#updateTips"
"#upload": "#upload"
"#url": "#url"
"AUTOTAG_OPTION": "#AUTOTAG_OPTION"
"COMPLETION_TYPE": "#COMPLETION_TYPE"
---
## Remote.addFetch Sync
```js
var result = Remote.addFetch(repo, remote, refspec);
```
| Parameters | Type | |
| --- | --- | --- |
| repo | [Repository](/api/repository/) | the repository in which to change the configuration |
| remote | String | the name of the remote to change |
| refspec | String | the new fetch refspec |
| Returns | |
| --- | --- |
| Number | 0, GIT_EINVALIDSPEC if refspec is invalid or an error value |
## Remote.addPush Sync
```js
var result = Remote.addPush(repo, remote, refspec);
```
| Parameters | Type | |
| --- | --- | --- |
| repo | [Repository](/api/repository/) | the repository in which to change the configuration |
| remote | String | the name of the remote to change |
| refspec | String | the new push refspec |
| Returns | |
| --- | --- |
| Number | 0, GIT_EINVALIDSPEC if refspec is invalid or an error value |
## Remote.create Async
```js
Remote.create(repo, name, url).then(function(remote) {
// Use remote
});
```
| Parameters | Type | |
| --- | --- | --- |
| repo | [Repository](/api/repository/) | the repository in which to create the remote |
| name | String | the remote's name |
| url | String | the remote's url |
| Returns | |
| --- | --- |
| [Remote](/api/remote/) | the resulting remote |
## Remote.createAnonymous Async
```js
Remote.createAnonymous(repo, url).then(function(remote) {
// Use remote
});
```
| Parameters | Type | |
| --- | --- | --- |
| repo | [Repository](/api/repository/) | the associated repository |
| url | String | the remote repository's URL |
| Returns | |
| --- | --- |
| [Remote](/api/remote/) | |
## Remote.createDetached Async
```js
Remote.createDetached(url).then(function(remote) {
// Use remote
});
```
| Parameters | Type | |
| --- | --- | --- |
| url | String | the remote repository's URL |
| Returns | |
| --- | --- |
| [Remote](/api/remote/) | |
## Remote.createWithFetchspec Async
```js
Remote.createWithFetchspec(repo, name, url, fetch).then(function(remote) {
// Use remote
});
```
| Parameters | Type | |
| --- | --- | --- |
| repo | [Repository](/api/repository/) | the repository in which to create the remote |
| name | String | the remote's name |
| url | String | the remote's url |
| fetch | String | the remote fetch value |
| Returns | |
| --- | --- |
| [Remote](/api/remote/) | the resulting remote |
## Remote.delete Async
```js
Remote.delete(repo, name).then(function(result) {
// Use result
});
```
| Parameters | Type | |
| --- | --- | --- |
| repo | [Repository](/api/repository/) | the repository in which to act |
| name | String | the name of the remote to delete |
| Returns | |
| --- | --- |
| Number | 0 on success, or an error code. |
## Remote.isValidName Sync
```js
var result = Remote.isValidName(remote_name);
```
| Parameters | Type | |
| --- | --- | --- |
| remote_name | String | name to be checked. |
| Returns | |
| --- | --- |
| Number | 1 if the reference name is acceptable; 0 if it isn't |
## Remote.list Async
```js
Remote.list(repo).then(function(array) {
// Use array
});
```
| Parameters | Type | |
| --- | --- | --- |
| repo | [Repository](/api/repository/) | the repository to query |
| Returns | |
| --- | --- |
| Array | a string array which receives the names of the remotes |
## Remote.lookup Async
```js
Remote.lookup(repo, name, callback).then(function(remote) {
// Use remote
});
```
Retrieves the remote by name
| Parameters | Type | |
| --- | --- | --- |
| repo | [Repository](/api/repository/) | The repo that the remote lives in |
| name | String, [Remote](/api/remote/) | The remote to lookup |
| callback | Function | |
| Returns | |
| --- | --- |
| [Remote](/api/remote/) | |
## Remote.setAutotag Sync
```js
var result = Remote.setAutotag(repo, remote, value);
```
| Parameters | Type | |
| --- | --- | --- |
| repo | [Repository](/api/repository/) | the repository in which to make the change |
| remote | String | the name of the remote |
| value | Number | the new value to take. |
| Returns | |
| --- | --- |
| Number | |
## Remote.setPushurl Sync
```js
var result = Remote.setPushurl(repo, remote, url);
```
| Parameters | Type | |
| --- | --- | --- |
| repo | [Repository](/api/repository/) | the repository in which to perform the change |
| remote | String | the remote's name |
| url | String | the url to set |
| Returns | |
| --- | --- |
| Number | |
## Remote.setUrl Sync
```js
var result = Remote.setUrl(repo, remote, url);
```
| Parameters | Type | |
| --- | --- | --- |
| repo | [Repository](/api/repository/) | the repository in which to perform the change |
| remote | String | the remote's name |
| url | String | the url to set |
| Returns | |
| --- | --- |
| Number | 0 or an error value |
## Remote#autotag Sync
```js
var result = remote.autotag();
```
| Returns | |
| --- | --- |
| Number | the auto-follow setting |
## Remote#connect Async
```js
remote.connect(direction, callbacks, proxyOpts, customHeaders, callback).then(function(number) {
// Use number
});
```
Connects to a remote
| Parameters | Type |
| --- | --- | --- |
| direction | [Enums.DIRECTION](/api/enums/#DIRECTION) | The direction for the connection |
| callbacks | [RemoteCallbacks](/api/remote_callbacks/) | The callback functions for the connection |
| proxyOpts | [ProxyOptions](/api/proxy_options/) | Proxy settings |
| customHeaders | Array<string> | extra HTTP headers to use |
| callback | Function | |
| Returns | |
| --- | --- |
| Number | error code |
## Remote#connected Sync
```js
var result = remote.connected();
```
| Returns | |
| --- | --- |
| Number | 1 if it's connected, 0 otherwise. |
## Remote#defaultBranch Async
```js
remote.defaultBranch().then(function(buf) {
// Use buf
});
```
| Returns | |
| --- | --- |
| [Buf](/api/buf/) | the buffern in which to store the reference name |
## Remote#disconnect Async
```js
remote.disconnect().then(function() {
// method complete});
```
## Remote#download Async
```js
remote.download(refSpecs, opts, callback).then(function(number) {
// Use number
});
```
Connects to a remote
| Parameters | Type |
| --- | --- | --- |
| refSpecs | Array | The ref specs that should be pushed |
| opts | [FetchOptions](/api/fetch_options/) | The fetch options for download, contains callbacks |
| callback | Function | |
| Returns | |
| --- | --- |
| Number | error code |
## Remote#dup Async
```js
remote.dup().then(function(remote) {
// Use remote
});
```
| Returns | |
| --- | --- |
| [Remote](/api/remote/) | the copy |
## Remote#fetch Async
```js
remote.fetch(refSpecs, opts, message, callback).then(function(number) {
// Use number
});
```
Connects to a remote
| Parameters | Type |
| --- | --- | --- |
| refSpecs | Array | The ref specs that should be pushed |
| opts | [FetchOptions](/api/fetch_options/) | The fetch options for download, contains callbacks |
| message | String | The message to use for the update reflog messages |
| callback | Function | |
| Returns | |
| --- | --- |
| Number | error code |
## Remote#getFetchRefspecs Async
```js
remote.getFetchRefspecs().then(function(array) {
// Use array
});
```
| Returns | |
| --- | --- |
| Array | |
## Remote#getPushRefspecs Async
```js
remote.getPushRefspecs().then(function(array) {
// Use array
});
```
| Returns | |
| --- | --- |
| Array | |
## Remote#getRefspec Sync
```js
var refspec = remote.getRefspec(n);
```
| Parameters | Type |
| --- | --- | --- |
| n | Number | the refspec to get |
| Returns | |
| --- | --- |
| [Refspec](/api/refspec/) | the nth refspec |
## Remote#name Sync
```js
var string = remote.name();
```
| Returns | |
| --- | --- |
| String | the name or NULL for in-memory remotes |
## Remote#owner Sync
```js
var repository = remote.owner();
```
| Returns | |
| --- | --- |
| [Repository](/api/repository/) | the repository |
## Remote#prune Sync
```js
var result = remote.prune(callbacks);
```
| Parameters | Type |
| --- | --- | --- |
| callbacks | [RemoteCallbacks](/api/remote_callbacks/) | callbacks to use for this prune |
| Returns | |
| --- | --- |
| Number | 0 or an error code |
## Remote#pruneRefs Sync
```js
var result = remote.pruneRefs();
```
| Returns | |
| --- | --- |
| Number | the ref-prune setting |
## Remote#push Async
```js
remote.push(refSpecs, options, callback).then(function(number) {
// Use number
});
```
Pushes to a remote
| Parameters | Type |
| --- | --- | --- |
| refSpecs | Array | The ref specs that should be pushed |
| options | [PushOptions](/api/push_options/) | Options for the checkout |
| callback | Function | |
| Returns | |
| --- | --- |
| Number | error code |
## Remote#pushurl Sync
```js
var string = remote.pushurl();
```
| Returns | |
| --- | --- |
| String | the url or NULL if no special url for pushing is set |
## Remote#referenceList Async
```js
remote.referenceList().then(function(promiseArrayRemoteHead) {
// Use promiseArrayRemoteHead
});
```
Lists advertised references from a remote. You must connect to the remote
before using referenceList.
| Returns | |
| --- | --- |
| Array<RemoteHead>> | a list of the remote heads the remote had available at the last established
connection. |
## Remote#refspecCount Sync
```js
var result = remote.refspecCount();
```
| Returns | |
| --- | --- |
| Number | the amount of refspecs configured in this remote |
## Remote#stats Sync
```js
var transferProgress = remote.stats();
```
| Returns | |
| --- | --- |
| [TransferProgress](/api/transfer_progress/) | |
## Remote#stop Sync
```js
remote.stop();
```
## Remote#updateTips Sync
```js
var result = remote.updateTips(callbacks, update_fetchhead, download_tags, reflog_message);
```
| Parameters | Type |
| --- | --- | --- |
| callbacks | [RemoteCallbacks](/api/remote_callbacks/) | pointer to the callback structure to use |
| update_fetchhead | Number | whether to write to FETCH_HEAD. Pass 1 to behave like git. |
| download_tags | Number | what the behaviour for downloading tags is for this fetch. This is ignored for push. This must be the same value passed to `git_remote_download()`. |
| reflog_message | String | The message to insert into the reflogs. If NULL and fetching, the default is "fetch ", where is the name of the remote (or its url, for in-memory remotes). This parameter is ignored when pushing. |
| Returns | |
| --- | --- |
| Number | 0 or an error code |
## Remote#upload Async
```js
remote.upload(refSpecs, options, callback).then(function(number) {
// Use number
});
```
Pushes to a remote
| Parameters | Type |
| --- | --- | --- |
| refSpecs | Array | The ref specs that should be pushed |
| options | [PushOptions](/api/push_options/) | Options for the checkout |
| callback | Function | |
| Returns | |
| --- | --- |
| Number | error code |
## Remote#url Sync
```js
var string = remote.url();
```
| Returns | |
| --- | --- |
| String | the url |
## Remote.AUTOTAG_OPTION ENUM
| Flag | Value |
| --- | --- | --- |
| Remote.AUTOTAG_OPTION.DOWNLOAD_TAGS_UNSPECIFIED | 0 |
| Remote.AUTOTAG_OPTION.DOWNLOAD_TAGS_AUTO | 1 |
| Remote.AUTOTAG_OPTION.DOWNLOAD_TAGS_NONE | 2 |
| Remote.AUTOTAG_OPTION.DOWNLOAD_TAGS_ALL | 3 |
## Remote.COMPLETION_TYPE ENUM
| Flag | Value |
| --- | --- | --- |
| Remote.COMPLETION_TYPE.COMPLETION_DOWNLOAD | 0 |
| Remote.COMPLETION_TYPE.COMPLETION_INDEXING | 1 |
| Remote.COMPLETION_TYPE.COMPLETION_ERROR | 2 |