使用这个 git 命令,我可以获得远程存储库的所有可用标签,而无需克隆它:
git ls-remote --tags https://github.com/blender/blender.git
Run Code Online (Sandbox Code Playgroud)
我想使用 来复制这个libgit2。
我可以使用git_tag_list(https://libgit2.org/libgit2/#HEAD/group/tag/git_tag_list)来获取标签列表,但它需要一个git_repository对象。我可以用来git_repository_open创建一个git_repository对象,但只有当存储库已被克隆并存在于磁盘本地时才有效。我似乎找不到任何git_repository使用远程存储库 URL 创建对象的方法。
libgit2 示例有该命令的实现ls-remote,因此它一定是可能的:
git ls-remote --tags https://github.com/blender/blender.git
Run Code Online (Sandbox Code Playgroud)
不幸的是这个命令还需要一个git_repository对象,所以我有点不知所措。目前如果不先克隆就不可能实现吗?
我正在尝试在web项目中使用libgit2sharp.问题是libgit2sharp的解决方案适用于VS2010而我正在使用VS2008.所以我不得不创建一个新的解决方案并修改代码而不使用默认参数.这不是问题,除了我尝试使用已编译的libgit2sharp DLL时,我在标题中列出了异常.
我已尝试在git2.dll中链接,但这没有帮助.将git2.dll复制到Web项目中也没有帮助.
编辑:问题是在LibGit2Sharp问题跟踪器上处理的:https://github.com/libgit2/libgit2sharp/issues/39
我正在循环提交LibGit2Sharp:
Repository repo = new Repository("Z:/www/gg");
foreach (LibGit2Sharp.Commit commit in repo.Commits)
{
...
}
Run Code Online (Sandbox Code Playgroud)
我可以检索像Author和的属性Message,但我没有看到它属于哪个分支?理想情况下,我希望有一个指向分支对象的指针,但在这种情况下,即使名称也没问题.
这是调试器显示的内容:

这就是我要找的东西:

TortoiseGit显示最相关分支名称的行为:

示例存储库:https://docs.google.com/open?id = 0B-3-X85VysdNcmZIaGVTSDZSenVGbTJxYlI2SUlsZw
是否可以使用ssh-keys通过ssh克隆存储库?
我正在使用pygit2处理非裸存储库
index = repo.index
index.read()
# write in test/test.txt
index.add('test/test.txt')
treeid = index.write_tree()
repo.create_commit(
'HEAD',
author, committer,
'test commit',
treeid,
[repo.head.oid]
)
Run Code Online (Sandbox Code Playgroud)
这很成功,但是当我执行时git status,我得到了这个:
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# deleted: test/test.txt
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# test/
Run Code Online (Sandbox Code Playgroud)
git reset --hard一切之后,一切都得到了解决.
有没有办法用pygit正确更新索引?
我通过另一种语言的FFI使用libgit2但是我很难搞清楚各种函数实际上做了什么(除非绝对必要,否则我不想求助于阅读源代码).有谁知道在哪里可以找到libgit2中某些函数的一些工作代码示例?
我需要在没有Git完成的自动合并提交的情况下获取提交列表.如何使用libgit2sharp包完成?
我搜索了Google和Stackoverflow,以获得如何在libgit2(https://libgit2.github.com)和C或C++中编写相当于git commit -a -m"message"的问题的答案.但我找不到这个问题的准备和工作答案.我使用的是libgit2-0.21.
下面是初始化git存储库,向其添加两个文件,并对这两个文件进行分级以便准备提交的代码.
我的问题是如何在libgit2中编写"git commit -a -m"msg"?
#include <sys/stat.h>
#include <string>
#include <fstream>
#include <iostream>
#include <git2.h>
using namespace std;
int main (int argc, char** argv)
{
git_threads_init ();
// Create repository directory.
string directory = "repository";
mkdir (directory.c_str(), 0777);
// Initialize the repository: git init.
git_repository *repo = NULL;
int result = git_repository_init (&repo, directory.c_str(), false);
if (result != 0) cerr << giterr_last ()->message << endl;
// Store two files in the repository directory.
ofstream …Run Code Online (Sandbox Code Playgroud) 我目前正在开发一个flashcard应用程序,其中用户创建的decks充当Git存储库.在应用程序中创建卡片时,会在更换卡片,更改文件以及删除卡片时将新文件提交到存储库 - 嗯,您明白了.
应用程序保存到的文件格式是一个gzip压缩的Git存储库,所以在任何时候我都不需要将存储库写入磁盘.我怎样才能以这种方式最好地处理甲板作为Git存储库?
我一直在查看libgit2 C API参考,但我不知道如何模仿它的行为git commit --allow-empty.libgit2是否有内置的方法来创建空提交?如果没有,git如何在引擎盖下创建一个空提交,我应该如何使用libgit2实现相同的行为?