Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions examples/checkout-remote-branch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
var nodegit = require("../");
var path = require("path");

var remoteBranchName = "REMOTE-BRANCH-NAME";

nodegit.Repository.open(path.resolve(__dirname, "../.git"))
.then(function(repo) {

return repo.getHeadCommit()
.then(function (targetCommit) {
return repo.createBranch(remoteBranchName, targetCommit, false);
})
.then(function (reference) {
return repo.checkoutBranch(reference, {});
})
.then(function () {
return repo.getReferenceCommit(
"refs/remotes/origin/" + remoteBranchName);
})
.then(function (commit) {
nodegit.Reset.reset(repo, commit, 3, {});
});

}).done(function() {
console.log("All done!");
});
2 changes: 1 addition & 1 deletion guides/cloning/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ a function to attempt opening in this case.

``` javascript
var errorAndAttemptOpen = function() {
return NodeGit.Repository.open(local);
return NodeGit.Repository.open(localPath);
};
```

Expand Down
2 changes: 1 addition & 1 deletion guides/cloning/gh-two-factor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ a function to attempt opening in this case.

``` javascript
var errorAndAttemptOpen = function() {
return NodeGit.Repository.open(local);
return NodeGit.Repository.open(localPath);
};
```

Expand Down
2 changes: 1 addition & 1 deletion guides/cloning/ssh-with-agent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ a function to attempt opening in this case.

``` javascript
var errorAndAttemptOpen = function() {
return NodeGit.Repository.open(local);
return NodeGit.Repository.open(localPath);
};
```

Expand Down
2 changes: 1 addition & 1 deletion lib/reference.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Reference.prototype.isConcrete = function() {

/**
* Returns if the ref is pointed at by HEAD
* @return {bool}
* @return {Boolean}
*/
Reference.prototype.isHead = function() {
return Branch.isHead(this);
Expand Down
2 changes: 1 addition & 1 deletion lib/repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ Repository.prototype.continueRebase = function(
* @async
* @param {String} name Branch name, e.g. "master"
* @param {Commit|String|Oid} commit The commit the branch will point to
* @param {bool} force Overwrite branch if it exists
* @param {Boolean} force Overwrite branch if it exists
* @return {Reference}
*/
Repository.prototype.createBranch = function(name, commit, force) {
Expand Down
5 changes: 1 addition & 4 deletions lib/reset.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Reset.default = function(repo, target, pathspecs) {
};

/**
* Look up a refs's commit.
* Reset a repository's current HEAD to the specified target.
*
* @async
* @param {Repository} repo Repository where to perform the reset operation.
Expand All @@ -41,9 +41,6 @@ Reset.default = function(repo, target, pathspecs) {
* used to propagate notify and progress
* callbacks.
*
* @param {String|Ref} name Ref name, e.g. "master", "refs/heads/master"
* or Branch Ref
*
* @return {Number} 0 on success or an error code
*/
Reset.reset = function(repo, target, resetType, opts) {
Expand Down