我正在尝试使用go-git以编程方式实现以下git命令的结果:
git fetch
git reset --hard origin/<some_branch>
因此,存在
git.Worktree.Reset()
,它获得git.ResetOptions
,它具有Commit
类型的plumbing.Hash
属性。不幸的是,我不知道如何获取origin/<some_branch>
的哈希值。我怎样才能做到这一点?
最佳答案
从命令行使用Git时,您需要使用rev-parse
(请参阅How to find the hash of branch in Git?)。
它似乎在go-git中部分实现:
存在一种满足的方法(*Repository).ResolveRevision
rev-parse
的部分行为
资料来源:https://github.com/src-d/go-git/issues/599
关于git - go-git:是否可以对原始分支执行硬重置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58247194/