How do I check the date and time of the latest `gi

2020-02-02 06:47发布

How do I check the date and time of the latest git pull that was executed? I frequently need to know when the code changed on a server when something goes wrong.

标签: git git-pull
10条回答
对你真心纯属浪费
2楼-- · 2020-02-02 07:12
git show -1 --stat  

This git command shows the latest changes commits time and date with message

查看更多
贪生不怕死
3楼-- · 2020-02-02 07:12

As suggested by user: https://stackoverflow.com/users/83646/smoove, you can find when git pull was last called on the repo by checking the modification timestamp of: .git/FETCH_HEAD as: git writes the .git/FETCH_HEAD file every time you pull or fetch, even if there was nothing to pull.

Example: {master} vinegupt@bhling69(/imsgit_local/work/vinegupt/ims_18.5a/ims_common)$ stat -c %y .git/FETCH_HEAD

2018-02-12 02:01:50.487160386 +0530

查看更多
ゆ 、 Hurt°
4楼-- · 2020-02-02 07:17

In a non-bare repository (and a bare repository doesn't make sense for git pull), git logs all changes to branch tips and the current branch idea in "reflogs", in .git/logs. You can view these using git log -g.

However, although the log files do have timestamps, it doesn't appear that git log -g will print it. However, if you take a look at .git/logs/HEAD for example, you'll see that the format is quite simple to parse- it consists of what the ref (or HEAD) changed from, changed to, who changed it, when and an activity message.

查看更多
We Are One
5楼-- · 2020-02-02 07:21

The git show command shows the date of the most recent commit. This isn't the date at which the commit was pulled to the local repository, but Git doesn't keep such pull information.

You may be able to find the time of the last pull using the ctime (creation time) of the files on the server. For example:

ls -lct

shows the ctime of each file, sorted with the most recent first.

查看更多
登录 后发表回答