我正在尝试使用nodejs模块,gift读取 Git 存储库的索引。我选择“gift”是因为它在 Windows 上似乎最有前途。有谁知道如何使用此模块获取 Git 存储库的状态?我基本上只想在我的 Git 存储库上执行状态命令。
$ git status
还有其他在 Windows 上运行良好的 Nodejs Git 模块吗?
谢谢!
解决方案
查看源代码后,我发现 Status 是一个附加到 Repo 的对象。您按照我选择的答案中的描述使用它。
Windows 警告 - 我必须 add git to my system path然后重新启动。一定喜欢 Windows :\即使在将 git 添加到我的系统路径并在 cmd.exe 中测试它之后,gift 仍然抛出错误:
command failed: 'git' is not recognized as an internal or external command, operable program or batch file.
重新启动后一切都很好。
最佳答案
你可以这样获取状态
git = require 'gift'
repo = git "path/to/repo"
repo.status(callback)
回调接收(err, status)
。状态具有属性
status.clean
bool 值,如果工作树干净则为 true
status.files
对象 - 键是文件,值对象指示文件是否暂存、跟踪等。
每个文件都具有以下属性:
- 类型 - “A”表示添加,“M”表示修改,“D”表示删除。
- 已上演 - bool 值
- 跟踪 - bool 值
此信息来源:the documentation .
关于windows - NodeJs - 在 Windows 上访问 Git 索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17154705/