Information and links may be outdated.
Restoring modification timestamps in cloned git repos
I have a GitHub Actions Workflow that clones the repo, renders the content, then pushes it up to the gh-pages
branch to be published. However, the ordering of the field notes was dependent on the file modification timestamps. I imagine workflows that use Make will also be affected by this issue.
I needed a solution that restored the modification timestamps after the repo is cloned. I chanced upon git-tools
which contained a utility called git-restore-mtime
that served this purpose perfectly.
To achieve this, I added a step to install and execute after cloning. Additionally, the whole history needs to be cloned by setting fetch-depth
to 0
for the actions/checkout
action.1
- name: Check out repository
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Restore modification timestamps
run: sudo apt-get install -y git-restore-mtime && git restore-mtime
Note that this requires git
and a modern python
version. GitHub Actions does come with Python pre-installed, so this works well.
content/notes/til/git_restore_mtime.html learning/git-restore-mtime
-
I presume that the modification times are taken from the git log, but I may be mistaken. ↩︎