Skip to content

Commit 9ba9487

Browse files
committed
Remote creation
1 parent e1a2b5a commit 9ba9487

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

docs/guides/101-samples/index.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,25 +1355,47 @@ int error = git_remote_list(&remotes, repo);
13551355
<h3 id="remotes_load">Loading</h3>
13561356

13571357
```c
1358+
git_remote *remote = NULL;
1359+
int error = git_remote_load(&remote, repo, "origin");
13581360
```
13591361
(
1360-
[``](),
1362+
[`git_remote_load`](http://libgit2.github.com/libgit2/#HEAD/group/remote/git_remote_load)
13611363
)
13621364

13631365
<h3 id="remotes_create">Creating</h3>
13641366

1367+
Both of these methods save the remote configuration to disk before returning.
1368+
13651369
```c
1370+
/* Creates an empty remote */
1371+
git_remote *newremote = NULL;
1372+
int error = git_remote_create(&newremote, repo, "upstream",
1373+
"https://github.com/libgit2/libgit2");
1374+
1375+
/* Pre-populates a new remote with a fetchspec */
1376+
git_remote *newremote2 = NULL;
1377+
error = git_remote_create(&newremote2, repo, "upstream2",
1378+
"https://github.com/libgit2/libgit2", /* URL */
1379+
"+refs/heads/*:refs/custom/namespace/*"); /* fetchspec */
13661380
```
13671381
(
1368-
[``](),
1382+
[`git_remote_create`](http://libgit2.github.com/libgit2/#HEAD/group/remote/git_remote_create),
1383+
[`git_remote_create_with_fetchspec`](http://libgit2.github.com/libgit2/#HEAD/group/remote/git_remote_create_with_fetchspec)
13691384
)
13701385

13711386
<h3 id="remotes_in_memory">Creating (in-memory)</h3>
13721387

1388+
This method creates a remote that cannot be saved.
1389+
This is useful for one-time fetches.
1390+
13731391
```c
1392+
git_remote *remote;
1393+
int error = git_remote_create_inmemory(&remote, repo,)
1394+
"+refs/heads/*:refs/custom/namespace/*", /* fetchspec */
1395+
"https://github.com/libgit2/libgit2"); /* URL */
13741396
```
13751397
(
1376-
[``](),
1398+
[`git_remote_create_inmemory`](http://libgit2.github.com/libgit2/#HEAD/group/remote/git_remote_create_inmemory)
13771399
)
13781400

13791401
<h3 id="remotes_rename">Renaming</h3>

0 commit comments

Comments
 (0)