在Git提交中对文件进行排序。

huangapple go评论64阅读模式
英文:

files orders in git commit

问题

Is there any way to know which file, in a given Git commit, was created first and list said files in order they were created?
有没有办法知道在给定的Git提交中,哪个文件是最早创建的,并按它们创建的顺序列出这些文件?

Note that their dates are equal to the commit date and we cannot use that date.
请注意,它们的日期与提交日期相同,我们不能使用该日期。

Imagine I have 3 files in 1 commit: a.js, b.js, and c.js.
假设我在一个提交中有3个文件:a.jsb.jsc.js

And they are not related to each other, so we can use their dependencies.
它们彼此之间没有关联,所以我们不能使用它们的依赖关系。

What should I do to achieve that goal?
要实现这个目标,我应该怎么做?

I already tried to use git log, but the output is not in any specific order.
我已经尝试使用git log,但输出不按特定顺序排列。

And I tried to use the file date in commit, but they were all the same, as mentioned before.
我尝试使用提交中的文件日期,但如前所述,它们都相同。

英文:

Is there any way to know which file, in a given Git commit, was created first and list said files in order they were created?

Note that their dates are equal to the commit date and we cannot use that date.

Imagine I have 3 files in 1 commit : a.js, b.js and c.js.
And they are not related to each other, so we can use their dependencies.
What should I do to achieve that goal?

I already tried to use git log, but the output is not in any specific order.
And I tried to use the file date in commit, but they were all the same, as mentioned before.

答案1

得分: 2

  • git utime,这会将文件的修改时间更改为它们的最后提交日期。

  • 或者 git restore-mtime,已打包到Debian、Ubuntu、Linux Mint、Fedora、Gentoo Linux等发行版中。

  • git meta 会将所有文件的元数据存储到 '.gitmeta' 中。

这些工具中的任何一个都会让您更接近按创建顺序查看文件。

英文:

Git does not store the file-time, as I explained before (other explanation by torek).

But you have:

  • git utime, which changes files modification time to their last commit date.

  • Or git restore-mtime, packaged into Debian, Ubuntu, Linux Mint, Fedora, Gentoo Linux, and possibly other distributions.

  • git meta which stores all files' metadata into '.gitmeta'.

Any of those tools would bring you closer to seeing the files in order they were created.

huangapple
  • 本文由 发表于 2023年3月31日 18:10:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/75897308.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定