go-git: 是否可以硬重置到 origin 分支?
go-git: Is it possible to perform a hard reset to origin branch?
我正在尝试使用 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:
中好像部分实现了
There exists a method (*Repository).ResolveRevision which satisfies
part of the behavior of rev-parse
我正在尝试使用 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:
中好像部分实现了There exists a method (*Repository).ResolveRevision which satisfies part of the behavior of
rev-parse