gpt4 book ai didi

git - commit time 在未来的后果

转载 作者:行者123 更新时间:2023-12-04 14:09:40 25 4
gpt4 key购买 nike

当我的设备日期时间设置为 future 几天(即日期设置为 23 日而不是 21 日)时,我不小心向 Remote 提交并推送了更改。

我提到了 this这将解决我的问题,但由于强制推送,建议不要执行它。

所以我的问题是保持错误的提交日期和时间会对 Git 存储库(本地和远程)产生不利影响。我使用“Git Lab”作为我的远程存储库提供程序。

最佳答案

So my question is will keeping the wrong date and time of a commitadversely effect the Git repo (Local & Remote). I use "Git Lab" as myremote repository provider.

答案是:“视情况而定”。从 git 的角度来看,它不是:日期被记录为元数据,提交顺序是基于父/子关系提供的。请看this answer进一步研究。

但是,如果您employ CI scripts或者非常关心存储库的实际历史,从广义上讲,记录错误的元数据不好。它可以修复。

附带说明一下,您可以使用元数据做很多事情,例如但不限于 creating commits in the past .

Committing

The final creation of a Git commit object is usually done by git-commit-tree, which uses these environment variables as itsprimary source of information, falling back to configuration valuesonly if these aren’t present.

GIT_AUTHOR_NAME is the human-readable name in the “author” field.

GIT_AUTHOR_EMAIL is the email for the “author” field.

GIT_AUTHOR_DATE is the timestamp used for the “author” field.

GIT_COMMITTER_NAME sets the human name for the “committer” field.

GIT_COMMITTER_EMAIL is the email address for the “committer” field.

GIT_COMMITTER_DATE is used for the timestamp in the “committer”field.

EMAIL is the fallback email address in case the user.emailconfiguration value isn’t set. If this isn’t set, Git falls back tothe system user and host names.source

这是理解 git 内部结构的另一个很好的引用:

Let us consider the hashes of these objects for a bit. Let’s say Iwrote the string git is awesome! and created a blob from it. You didthe same on your system. Would we have the same hash?

The answer is — Yes. Since the blobs consist of the same data, they’llhave the same SHA-1 values.

What if I made a tree that references the blob of git is awesome!, andgave it a specific name and metadata, and you did exactly the same onyour system. Would we have the same hash?

Again, yes. Since the trees objects are the same, they would have thesame hash.

What if I created a commit of that tree with the commit message Hello,and you did the same on your system. Would we have the same hash?

In this case, the answer is — No. Even though our commit objects referto the same tree, they have different commit details — time, committeretc.source

关于git - commit time 在未来的后果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65387595/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com