从Web界面初始化Git存储库

时间:2016-02-19 01:05:46

标签: node.js git web-applications amazon-ec2

我正在构建一个Web应用程序(无需深入了解这些技术的确切应用程序),这将允许用户创建存储库并相互共享。

我处于初始设计阶段,想知道从界面执行终端命令的最佳方法是什么。理想情况下,用户可以单击一个按钮,我会为它们初始化一个新的git存储库。

注意:在设计过程中,我将在安装了git的Amazon EC2实例上托管该网站。

1 个答案:

答案 0 :(得分:1)

总之,您需要从Node.js应用程序运行git。 “正在运行”git实际上是产生git进程,this is something you can do natively.

// 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);
});