从Web界面初始化Git存储库
我正在构build一个Web应用程序(无需进入这些技术的确切应用程序)将允许用户创build存储库并相互共享。
我正处于最初的devise阶段,想知道从接口执行terminal命令的最佳方法是什么。 理想情况下,用户将能够点击一个button,我会为他们初始化一个新的git存储库。
注意:在devise过程中,我将在安装了git的Amazon EC2实例上托pipe该站点。
总之,您需要从Node.js应用程序运行git
。 “运行” git
实际上是产生了git
进程, 这是你本可以做的事情。
// Spawn a git process. const spawn = require('child_process').spawn; const git = spawn('git', ['init']); // Hook into the close event. See the manual for other events. git.on('close', (code) => { // You can check the return code here to see if an error occured. console.log('git init finished with return code ' + code); });