javascript - 将 git 分支列表存储在变量中

标签 javascript git visual-studio-code

我正在尝试使用git分支将我的所有分支放入一个列表中。我当时想的是

    const branches = executecommand('git branch -l')

但我不知道正确的方法。

最佳答案

我认为 Node 核心中的 child_process 模块就是您想要的:

const cp = require('child_process')

const branches = cp.execSync('git branch -l')

https://nodejs.org/api/child_process.html

关于javascript - 将 git 分支列表存储在变量中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56877324/

相关文章:

javascript - 插件可以与 downthemall 插件通信吗?

git - 在 Jenkins/Git 中设置远程跟踪

visual-studio-code - 在 VSCode 扩展中设置文本文档的语言

visual-studio-code - 有没有办法在 VS Code 中禁用选择突出显示?

visual-studio-code - VS Code中多个文件中的断点?

javascript - 使用 zeromq.js 从 nodejs 应用程序与 python 后端进行通信

javascript - 使用 JavaScript 控制台修改脚本的结果

javascript - 使用 next() 填写时显示下一个输入字段

git - 使用另一个文件夹中的 git "log"

Git - 多环境开发