Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要知道当前已签出哪个分支。
我看到的一种解决方案是列出分支并检查哪个'==='当前'HEAD'。还有其他方法吗?
使用此代码:
import * as Git from 'nodegit'; let repo: Git.Repository = await Git.Repository.open("path to the repo"); let currentBranch: Git.Reference = await repo.getCurrentBranch(); let currentBranchName: string = currentBranch.shorthand();