In the past I've blogged about checking out branches created on a specific date as well as sorting git branches by date, but one frequent usage of git and dates is checking out a commit at a given time in the past. For example, I often say "Weird, this feature was working a month ago" or "We removed that UI two months ago, how did it look again?". I don't care about the branch previous to the change, I just want to go back a given timeframe and see something.
过去,我写过关于签出在特定日期创建的分支以及按日期对git分支进行排序的博客,但是git和date的一种常见用法是在过去的给定时间签出一次提交。 例如,我经常说“很奇怪,该功能一个月前就可以使用”或“我们两个月前就删除了该UI,它又看起来如何?”。 我不在乎更改之前的分支,我只想返回给定的时间范围并看到一些东西。
The following git command allows you checkout the commit closest to the given date and time:
以下git命令允许您检出最接近给定日期和时间的提交:
git checkout 'master@{2018-09-01 01:00:00}'
This command is incredibly useful -- I use it almost daily!
该命令非常有用-我几乎每天都在使用它!
翻译自: https://davidwalsh.name/git-checkout-at-previous-timeframe