简体   繁体   中英

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?

But as I understand git reflog only makes sense in the context of a local repository. Meaning each time you do a completely fresh clone the git reflog will be empty for all branches. Is that correct?

Yes that is correct. If you clone a project the reflog is empty and the first entry is for example:

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.

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

The problem is that first entry: make sure to use 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.

See commit 46da295 (04 Jun 2020) by Johannes Schindelin ( dscho ) .
(Merged by Junio C Hamano -- gitster -- in commit 524caf8 , 18 Jun 2020)

clone/fetch : anonymize URLs in the reflog

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.

Let's scrub them before writing them to the reflog.

So if you clone with git clone https://me:MyGitHubPassword@github.com/xxxx , the first entry will be:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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