Harshdeep Singh
Harshdeep Singh

Reputation: 337

Getting the time when the file was committed on Github

I want to somehow want to see if there is a way to get the time for when a file was committed on Github. I have tried using PyGithub and GitPython, but they don't have any options as such. Does anyone know a way around this?

Upvotes: 0

Views: 300

Answers (1)

Lucas Batista Gabriel
Lucas Batista Gabriel

Reputation: 900

you can check the hour in the log

so do git log to check all commits hours.

but if you want an specific file, you should use the flag --follow

so try this:

git log --follow filename

another aproach

if you want just to check the date of an specific commit use this command

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

Pythonic way

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

or

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

Upvotes: 1

Related Questions