我想使用libgit2sharp实现git pull --tags
.如果我尝试做这样的拉动:
repo.Network.Pull(new Signature("name", "my@email.com", new DateTimeOffset()), new PullOptions());
然后我得到新的提交,但没有指向这些提交的新标签.我试图用来PullOptions
修改这样的行为:
var sig = new Signature("name", "my@email.com", new DateTimeOffset());
var opts = new PullOptions{ FetchOptions = new FetchOptions {TagFetchMode = TagFetchMode.All} };
repo.Network.Pull(sig, opts);
这将引发以下异常:
LibGit2Sharp.LibGit2SharpException: ref 'refs/remotes/origin/master' doesn't match the destination
at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)
at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result)
at LibGit2Sharp.Core.Proxy.git_remote_fetch(RemoteSafeHandle remote, Signature signature, String logMessage)
at LibGit2Sharp.Network.DoFetch(RemoteSafeHandle remoteHandle, FetchOptions options, Signature signature, String logMessage)
at LibGit2Sharp.Network.Fetch(Remote remote, FetchOptions options, Signature signature, String logMessage)
at LibGit2Sharp.Network.Pull(Signature merger, PullOptions options)
有任何想法吗?
I would like to use libgit2sharp to achieve git pull --tags
.
If I try to do a pull like this:
repo.Network.Pull(new Signature("name", "my@email.com", new DateTimeOffset()), new PullOptions());
then I get the new commits but not the new tags which are pointing to these commits.
I tried to use PullOptions
to modify the behaviour like this:
var sig = new Signature("name", "my@email.com", new DateTimeOffset());
var opts = new PullOptions{ FetchOptions = new FetchOptions {TagFetchMode = TagFetchMode.All} };
repo.Network.Pull(sig, opts);
This throws the following exception:
LibGit2Sharp.LibGit2SharpException: ref 'refs/remotes/origin/master' doesn't match the destination
at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)
at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result)
at LibGit2Sharp.Core.Proxy.git_remote_fetch(RemoteSafeHandle remote, Signature signature, String logMessage)
at LibGit2Sharp.Network.DoFetch(RemoteSafeHandle remoteHandle, FetchOptions options, Signature signature, String logMessage)
at LibGit2Sharp.Network.Fetch(Remote remote, FetchOptions options, Signature signature, String logMessage)
at LibGit2Sharp.Network.Pull(Signature merger, PullOptions options)
Any ideas?
Stangely, I can't find any --tags
option in the latest official git documentation.
However, in LibGit2Sharp you can perform the equivalent git fetch --all
using the following code (or one of the other .Fetch()
overloads):
repo.Network.Fetch(remote, new FetchOptions { TagFetchMode = TagFetchMode.All });
The current tip of LibGit2Sharp vNext
branch doesn't cringe with this code. However, as seen in the issue you've raised, version v0.20.x does indeed throws.
v0.21 will fix this issue.
本人是.net程序员,因为英语不行,使用工具翻译,希望对有需要的人有所帮助
如果本文质量不好,还请谅解,毕竟这些操作还是比较费时的,英语较好的可以看原文