简体   繁体   English

Git reflog 并进行新的克隆?

[英]Git reflog and doing a fresh clone?

If you want to track changes that have happened in your git repository you can use https://git-scm.com/docs/git-reflog eg to restore a branch if it was deleted locally/remotely by accident?如果您想跟踪在您的 git 存储库中发生的更改,您可以使用https://git-scm.com/docs/git-reflog例如,如果分支在本地/远程被意外删除,则可以恢复该分支?

But as I understand git reflog only makes sense in the context of a local repository.但据我所知, git reflog 仅在本地存储库的上下文中才有意义。 Meaning each time you do a completely fresh clone the git reflog will be empty for all branches.这意味着每次您进行全新的克隆时,所有分支的 git reflog 都将为空。 Is that correct?那是正确的吗?

Yes that is correct.是的,这是正确的。 If you clone a project the reflog is empty and the first entry is for example:如果你克隆一个项目,reflog 是空的,第一个条目是例如:

fd7cb08 HEAD@{0}: clone: from https://github.com/xxxx

Reference logs, or "reflogs", record when the tips of branches and other references were updated in the local repository.引用日志或“reflogs”记录了本地存储库中分支和其他引用的提示何时更新。

https://git-scm.com/docs/git-reflog https://git-scm.com/docs/git-reflog

The problem is that first entry: make sure to use Git 2.28+.问题在于第一个条目:确保使用 Git 2.28+。

Before Git 2.28 (Q3 2020), the reflog entries for " git clone " and " git fetch " did not anonymize the URL they operated on.在 Git 2.28(2020 年第 3 季度)之前,“ git clone ”和“ git fetch ”的引用日志条目没有对它们操作的 URL 进行匿名化处理。

See commit 46da295 (04 Jun 2020) by Johannes Schindelin ( dscho ) .请参阅Johannes Schindelin ( dscho ) 的commit 46da295 (2020 年 6 月 4 dscho
(Merged by Junio C Hamano -- gitster -- in commit 524caf8 , 18 Jun 2020) (由Junio C gitster合并-- gitster -- in commit 524caf8 ,2020 年 6 月 18 日)

clone/fetch : anonymize URLs in the reflog clone/fetch :匿名化引用日志中的 URL

Signed-off-by: Johannes Schindelin签字人:约翰内斯·辛德林

Even if we strongly discourage putting credentials into the URLs passed via the command-line, there is support for that, and users do do that.即使我们强烈反对将凭据放入通过命令行传递的 URL 中,也支持,并且用户会这样做

Let's scrub them before writing them to the reflog.让我们在将它们写入 reflog 之前擦洗它们。

So if you clone with git clone https://me:MyGitHubPassword@github.com/xxxx , the first entry will be:因此,如果您使用git clone https://me:MyGitHubPassword@github.com/xxxx ,则第一个条目将是:

46da295 HEAD@{0}: clone: from https://github.com/xxxx

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

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