Hi I am trying to do a git push origin master
command with the help of Nodegit
, but it is resulting in an error,
var Git = require('nodegit');
function gitRemoteLookUp(repoPath) {
var open = Git.Repository.open;
var Remote = Git.Remote;
open(repoPath).then(function(repo){
return Remote.lookup(repo, "origin");
}).then(function(remote){
var ref = "refs/heads/master:remotes/origin/master";
var firstPass = true;
var options = {
callbacks: {
credentials: function(url, userName) {
if (firstPass) {
firstPass = false;
if (url.indexOf("https") === -1) {
return Git.Cred.sshKeyFromAgent('XYZ');
} else {
return Git.Cred.userpassPlaintextNew('XYZ', "XYZ");
}
} else {
return Git.Cred.defaultNew();
}
},
certificateCheck: function() {
return 1;
}
}
};
return remote.push(ref, options);
}).catch(function(err){
console.log(err);
})
}
I am using our internal ssh github server, which from the git Bash, for each push is asking for Username and Password.
Hence in hence in the code I have used the similar example as mentioned in the github site and also in the test site.
Pls help on this !!!!!!