Search code examples
node.jsgithubnodegit

Nodegit create remote repository and make first push


Many people claim to have solved this problem in the following examples

However after testing these solutions out I'm given an error that claims the remote.setCallbacks(...) function is undefined. A quick check at the Nodegit API documentation

confirms that the remote.setCallbacks(...) function is indeed undefined. I tried this example code found on the Nodegit page

But this code freezes at the remote.push(...) command. How have people managed to actually push code to a remote repository using Nodegit? Any help on the issue I've found thus far has been a disappointment!


Solution

  • Unfortunately I was shooting myself in the foot all day. The reason the example code found at

    wasn't working was because the remote github repository wasn't created before running the code. I'm guessing execution froze at the remote.push(...) command because the push prompt would make a request for the repository and not get a valid response, at which point it would make another request but still not get a valid response. Over and over again this would continue. The nodegit promise chain needs to establish a connection with the remote repository before it can finish. Unfortunately the Nodegit API documentation lacks explanation for many offered functions. Oh well, the important thing is a solution was reached!