【问题标题】:Getting the time when the file was committed on Github获取文件在 Github 上提交的时间
【发布时间】:2016-10-10 17:14:02
【问题描述】:

我想以某种方式想看看是否有办法在 Github 上获得 file was committed时间。我尝试过使用PyGithubGitPython,但它们没有任何选项。有谁知道解决这个问题的方法吗?

【问题讨论】:

  • "committed on github" 毫无意义。你的意思是推送到github?还是在本地提交?
  • 推送到 github。对此感到抱歉。

标签: git github github-api gitpython pygithub


【解决方案1】:

您可以在log查看小时

git log 检查所有提交时间。

但是如果你想要一个特定的文件,你应该使用标志--follow

所以试试这个:

git log --follow filename

另一种方法

如果您只想检查特定提交的日期,请使用此命令

git show -s --format=%ci <commit>

Python 方式

import git 
g = git.Git("/path/to/your/repo") 
loginfo = g.log()
print loginfo

import git 
g = git.Git("/path/to/your/repo") 
loginfo = g.log('--format=%ci <commit>')
print loginfo

【讨论】:

  • 有 Python 的方法吗?
  • 非常感谢,非常感谢 :)
  • 完成,当然。有没有办法让file也与每个提交相关联?
  • 获取文件使用:g.log('--', "YOUR_FILE_NAME.FILE_EXTENSION")
猜你喜欢
  • 2014-10-30
  • 2016-02-11
  • 2021-01-24
  • 2016-12-30
  • 2023-02-03
  • 2011-12-10
  • 1970-01-01
  • 2020-12-16
相关资源
最近更新 更多