Skip to content

Commit 2627e28

Browse files
author
John Haley
committed
Add create branch example
1 parent 417cb4f commit 2627e28

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

examples/create-branch.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
var nodegit = require("../");
2+
var path = require("path");
3+
var Promise = require("nodegit-promise");
4+
var promisify = require("promisify-node");
5+
var fse = promisify(require("fs-extra"));
6+
7+
nodegit.Repository.open(path.resolve(__dirname, "../.git"))
8+
.then(function(repo) {
9+
// Create a new branch on head
10+
return repo.getHeadCommit()
11+
.then(function(commit) {
12+
return repo.createBranch(
13+
"new-branch",
14+
commit,
15+
0,
16+
repo.defaultSignature(),
17+
"Created new-branch on HEAD");
18+
})
19+
}).done(function() {
20+
console.log("All done!");
21+
});

0 commit comments

Comments
 (0)