FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
nodegit/examples/checkout-remote-branch.js at master · iggue/nodegit · GitHub
iggue
nodegit
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
nodegit
/
examples
/
checkout-remote-branch.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
26 lines (22 loc) · 715 Bytes
Breadcrumbs
nodegit
/
examples
/
checkout-remote-branch.js
Copy path
File metadata and controls
26 lines (22 loc) · 715 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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!"
)
;
}
)
;
Back
|
FazBrowse Home
|
New Git URL