https://github.com/jonschlinkert/git-add-remote
API for adding git remotes.
https://github.com/jonschlinkert/git-add-remote
add api git javascript nodejs remote
Last synced: about 1 year ago
JSON representation
API for adding git remotes.
- Host: GitHub
- URL: https://github.com/jonschlinkert/git-add-remote
- Owner: jonschlinkert
- License: mit
- Created: 2017-04-19T23:43:40.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-20T01:40:28.000Z (about 9 years ago)
- Last Synced: 2025-04-29T16:09:43.963Z (about 1 year ago)
- Topics: add, api, git, javascript, nodejs, remote
- Language: JavaScript
- Homepage: https://github.com/jonschlinkert/git-add-remote
- Size: 7.81 KB
- Stars: 6
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: .github/contributing.md
- License: LICENSE
Awesome Lists containing this project
README
# git-add-remote [](https://www.npmjs.com/package/git-add-remote) [](https://npmjs.org/package/git-add-remote) [](https://npmjs.org/package/git-add-remote) [](https://travis-ci.org/jonschlinkert/git-add-remote)
> API for adding git remotes.
## Install
Install with [npm](https://www.npmjs.com/):
```sh
$ npm install --save git-add-remote
```
Install with [yarn](https://yarnpkg.com):
```sh
$ yarn add git-add-remote
```
## Usage
The main export is a function that must be called with the current working directory to initialize git from. Leave it undefined to use `process.cwd()`.
```js
var cwd = 'foo/bar';
var addRemote = require('git-add-remote')(cwd);
// async
addRemote(name, url, callback);
// sync (requires node.js v0.11.12 or higher)
addRemote.sync(name, url);
```
## async
**Examples**
```js
var addRemote = require('git-add-remote')();
addRemote('foo', 'https://foo.git', function(err) {
if (err) return console.log(err);
});
```
## sync
**Examples**
```js
var addRemote = require('git-add-remote')();
addRemote.sync('foo', 'https://foo.git');
addRemote.sync('bar', 'https://bar.git');
addRemote.sync('baz', 'https://baz.git');
```
## About
### Related projects
* [gfc](https://www.npmjs.com/package/gfc): Simple way to initialize a new git repository in an empty directory, add a file… [more](https://github.com/jonschlinkert/gfc) | [homepage](https://github.com/jonschlinkert/gfc "Simple way to initialize a new git repository in an empty directory, add a file and do a first commit (or skip that part in a directory with files). Useful for unit tests and generators.")
* [git-branch](https://www.npmjs.com/package/git-branch): Get the current branch for a local git repository. | [homepage](https://github.com/jonschlinkert/git-branch "Get the current branch for a local git repository.")
* [git-user-email](https://www.npmjs.com/package/git-user-email): Get the email address of the current user from git config. | [homepage](https://github.com/jonschlinkert/git-user-email "Get the email address of the current user from git config.")
* [git-user-name](https://www.npmjs.com/package/git-user-name): Get a user's name from git config at the project or global scope, depending on… [more](https://github.com/jonschlinkert/git-user-name) | [homepage](https://github.com/jonschlinkert/git-user-name "Get a user's name from git config at the project or global scope, depending on what git uses in the current context.")
* [git-username](https://www.npmjs.com/package/git-username): Get the username from a git remote origin URL. | [homepage](https://github.com/jonschlinkert/git-username "Get the username from a git remote origin URL.")
* [list-git-remotes](https://www.npmjs.com/package/list-git-remotes): List the remotes for a local git repository. Sync and async. | [homepage](https://github.com/jonschlinkert/list-git-remotes "List the remotes for a local git repository. Sync and async.")
### Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
Please read the [contributing guide](.github/contributing.md) for advice on opening issues, pull requests, and coding standards.
### Building docs
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
To generate the readme, run the following command:
```sh
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```
### Running tests
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
```sh
$ npm install && npm test
```
### Author
**Jon Schlinkert**
* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
### License
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT License](LICENSE).
***
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.5.0, on April 19, 2017._