Skip to content

Commit dc814a4

Browse files
author
John Haley
committed
Added an example for pull with merge
1 parent e882bc1 commit dc814a4

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

‎example/pull.js‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
var nodegit = require('../');
2+
var path = require('path');
3+
4+
var repoDir = '../../test';
5+
6+
var repository;
7+
8+
// Open a repository that needs to be fetched and fast-forwarded
9+
nodegit.Repository.open(path.resolve(__dirname, repoDir))
10+
.then(function(repo) {
11+
repository = repo;
12+
13+
return repository.fetchAll({
14+
credentials: function(url, userName) {
15+
return nodegit.Cred.sshKeyFromAgent(userName);
16+
}
17+
}, true);
18+
})
19+
// Now that we're finished fetching, go ahead and merge our local branch
20+
// with the new one
21+
.then(function() {
22+
repository.mergeBranches("master", "origin/master");
23+
})
24+
.done(function() {
25+
console.log("Done!");
26+
})

0 commit comments

Comments
 (0)