Answer the question
In order to leave comments, you need to log in
Nodejs script to upload to the repository.?
I wondered: - Is it possible to create a script that will automatically commit files to github?
- Probably yes, and probably it needs to be done through the execution of commands in git bash. I answered myself and rummaged through the Internet.
Created a repository manually Manually made a couple of commits.
Then he prescribed
var exec = require('child_process').exec;
exec('git status',{cwd:'./public/'},function(error,stdout,stderr){console.log(stdout);});
On branch master
Your branch is up to date with 'origin/master'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: library.js
modified: library.min.js
exec('git add .',{cwd:'./public/'},function(error,stdout,stderr){console.log(stdout);});
On branch master
Your branch is up to date with 'origin/master'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: library.js
modified: library.min.js
exec('git commit -m ""',{cwd:'./public/'},function(error,stdout,stderr){console.log(stdout);});
exec('git push -u origin master',{cwd:'./public/'},function(error,stdout,stderr){console.log(stdout);});
Branch 'master' set up to track remote branch 'master' from 'origin'.
Answer the question
In order to leave comments, you need to log in
Decided so
var exec = require('child_process').exec;
exec('git init',{cwd:'./public/'},function(error,stdout,stderr){
exec('git status',{cwd:'./public/'},function(error,stdout,stderr){
exec('git add .',{cwd:'./public/'},function(error,stdout,stderr){
exec('git commit -m "sadsdasd"',{cwd:'./public/'},function(error,stdout,stderr){
exec('git push origin master:username,{cwd:'./public/'},function(error,stdout,stderr){
});
});
});
});
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question