1

I have a code where I am downloading lot of files from S3/Azure. I want to push them to new repository in github using NodeJS code. Tried simpleGit module but it didnt workout. Here is the thing which I want to do - Create a new repository in github if not exists already - create files on fly with data I have and add them git repository. - commit those changes - push them to remote

Tried SimpleGit, NodeGit...but none of them have proper examples to do this task.

1 Answer 1

1

From what you are saying, you are trying to create a new repo on github before pushing to it. I think your issue is that you can't use git to create a github repo directly. They are two different things. For creating a new github repo you should use the github API https://developer.github.com/v3/repos/#create

When your repository is done, you should then be able to push to it with git and the libs you mentionned should do the trick.

When the repository is created follow the step here but with the equivalent commands from simpleGit (or any other lib, but this is the first you cited)

https://help.github.com/en/articles/adding-an-existing-project-to-github-using-the-command-line

Step 4 to the end (but don't do it directly, that's just to show what is needed to do)

And from simpleGit documentation

https://www.npmjs.com/package/simple-git#starting-a-new-repo

This example should do exactly what you need. You can try to find which command correspond to which of the step describe in the github doc.

Sign up to request clarification or add additional context in comments.

5 Comments

I created a repository at github. But how to create files only fly and push them to that repository?
Ok, that was to be sure. If the repo exist, this shouldn't be to complexe to do. Simplegit readme as most of the step you need on it. I'll edit my answer with revelant links
Here issue is files are not present in local file system. i have filename and filedata in nodejs array. And I dont want to create a separate file locally which will take lot of time as I have more than 5k files to send to git repository. I want to create a file at runtime (not physical file) and push it to repository.
Ok I see, that's another level and you won't find a simple way to do it. Git work by reading the disk, and libs like simpleGit are simply command line wrapper, they can't fundamentally change that. You can try to either mock git requests to github, or load yours data in a memory file system, but I have never tried it.
its working after using node-rest-client module in node

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.