如何在现有裸仓库中创建reflogs信息 [英] How to create reflogs information in an existing bare repository
问题描述
正如您可能已经知道,默认情况下,git不会为新的裸存储库启用reflog更新。问题是,我有一个很长的历史信息库,但它是在我设置标志logAllRefUpdates之前创建的,现在我希望这些信息可以用于其他应用程序。
As you might have known that by default, git doesn't enable reflog updates for new bare repositories. The problem is, I have a long history repository but it was created before I set the flag "logAllRefUpdates" on, and now I want that information for another application to work.
如何通过对现有存储库进行最小限度的更改来实现这一目标。一个非常简单的解决方案就是推送一个我不想要的新提交(!): - )
How can I achieve that with minimal changes made to the existing repository. A very simple solution is pushing a new commit which I don't want to (!) :-)
推荐答案
一个相对简单的文件格式。下面是一个例子:
The reflog is a relatively simple file format. Here's an example:
] cat .git/logs/HEAD|sed 's/\t/<TAB>/'
0000000000000000000000000000000000000000 5cfe4256d98af22a570c78c5e3048391a90f5f98 Joe User <foo@example.com> 1306427954 -0400<TAB>clone: from git://git.kernel.org/pub/scm/git/git.git
您可以按照相同的格式手动构建适当的reflog:
You can manually construct appropriate reflogs by following the same format:
previous-ref-or-zero new-ref User Name <user@email> unix-timestamp timezone\tmessage
只需为每个参考创建一个。你可以直接用 git for-each-ref
和适当的格式字符串来做到这一点(谢谢,Chris!)
Just create one of these for each ref. You can probably do this directly with git for-each-ref
with an appropriate format string (thanks, Chris!)
这篇关于如何在现有裸仓库中创建reflogs信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!