简体   繁体   English

有没有办法在git中推送reflog?

[英]Is there a way in git to push the reflog?

Is there a way to push the reflog to a remote? 有没有办法将reflog推送到远程? This seems like it would be an incredibly useful thing to do, but I do not know of a way to do it. 这似乎是一件非常有用的事情,但我不知道如何做到这一点。 I'm envisioning something like git push --include-reflogs 我正在设想像git push --include-reflogs这样git push --include-reflogs

In the end, I would want the remote to have a verbatim copy of the reflogs at the time of the push. 最后,我希望遥控器在推送时有一个逐字记录的reflogs副本。

I tried using --mirror , but 1) I don't want to delete any branches from this particular remote except manually, 2) it still didn't copy the reflogs over to the remote. 我尝试使用--mirror ,但1)我不想删除此特定远程的任何分支,除非手动,2)它仍然没有将reflogs复制到远程。

Does anyone know if/how this can be done? 有谁知道是否/如何做到这一点?

What you are really asking is, is there a way push around anonymous (that is, unreferenced) commit objects and their trees and blobs for backup purposes. 你真正要问的是,有没有办法推动匿名(即未引用)提交对象及其树和blob用于备份目的。 Answer is no. 答案是否定的。 Anonymous objects--objects that are only referenced by your reflog--are private to the local repo. 匿名对象 - 仅由您的reflog引用的对象 - 对本地仓库是私有的。

But --You can just copy the .git directory of any repo to do what you want. 但是 - 你可以复制任何仓库的.git目录来做你想要的。 If the source repo is busy (eg commits are happening, or a garbage collection or a repack) at the time then you need to copy files and directories in the .git directory in a certain order. 如果源仓库繁忙(例如,提交正在进行,或者是垃圾收集或重新打包),那么您需要按特定顺序复制.git目录中的文件和目录。 This is explained in various places but one example is http://article.gmane.org/gmane.comp.version-control.git/147354 ('If you want your rsync backup to be fine, you need to follow some ordering....') 这在不同的地方解释,但一个例子是http://article.gmane.org/gmane.comp.version-control.git/147354 ('如果你想让你的rsync备份正常,你需要遵循一些顺序。 ......“)

In short, what you need is just backup .git/logs . 简而言之,您需要的只是备份.git/logs

Actually, git stores reflog information under .git/log directory, you can do anything to them like open files in this directory with a text editor. 实际上,git将reflog信息存储在.git/log目录下,您可以对它们执行任何操作,例如使用文本编辑器在此目录中打开文件。 If you remove this directory, all reflog disappears and if you recover it, the reflog will be back. 如果删除此目录,则所有reflog消失,如果恢复,则reflog将返回。

As far as I know, there is no builtin way to track the .git/logs . 据我所知,没有内置的方法来跟踪.git/logs I have tried to move .git/log to working directory and make a symlink from .git directory to it. 我试图将.git/log移动到工作目录并从.git目录创建一个符号链接到它。 It works but not very well, because every time you do a commit, the HEAD moves and the .git/logs/HEAD changes, then you have a uncommited change now. 它工作但不是很好,因为每次你做提交, HEAD移动, .git/logs/HEAD改变,那么你现在有一个未经改变的改变。 The working directory will never be clean. 工作目录永远不会干净。

Git reflog tracks HEAD changes of a single Git repository. Git reflog跟踪单个Git存储库的HEAD更改。 Each clone has its own reflog. 每个克隆都有自己的reflog。 I can't figure out what you would do with a shared reflog (help someone remotely ?) 我无法弄清楚你会用共享的reflog做什么(远程帮助某人?)

If you really need to track someone's reflog, you could dump the reflog content in a file using git reflog > dev1_reflog.txt and share dev1_reflog.txt (using git add dev1_reflog.txt; git commit -m "Adding dev1_reflog"; git push ). 如果你真的需要跟踪某人的reflog,你可以使用git reflog > dev1_reflog.txt将reflog内容转储到一个文件中并共享dev1_reflog.txt (使用git add dev1_reflog.txt; git commit -m "Adding dev1_reflog"; git push ) 。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM