mirror of
https://github.com/jbranchaud/til
synced 2026-01-16 13:38:02 +00:00
Compare commits
4 Commits
13ddbd5dca
...
cc79596272
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc79596272 | ||
|
|
98d8249cf1 | ||
|
|
5615da920f | ||
|
|
c60c63f554 |
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
|
||||
|
||||
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
||||
|
||||
_1515 TILs and counting..._
|
||||
_1516 TILs and counting..._
|
||||
|
||||
---
|
||||
|
||||
@@ -190,7 +190,7 @@ _1515 TILs and counting..._
|
||||
- [Aliasing An Ansible Host](devops/aliasing-an-ansible-host.md)
|
||||
- [Allow Cross-Origin Requests To Include Cookies](devops/allow-cross-origin-requests-to-include-cookies.md)
|
||||
- [Allow HTTPS Through Your UFW Firewall](devops/allow-https-through-your-ufw-firewall.md)
|
||||
- [Check For Cached Site Assocation File For iOS](devops/check-for-cached-site-association-file-for-ios.md)
|
||||
- [Check For Cached Site Association File For iOS](devops/check-for-cached-site-association-file-for-ios.md)
|
||||
- [Check The Status of All Services](devops/check-the-status-of-all-services.md)
|
||||
- [Check The Syntax Of nginx Files](devops/check-the-syntax-of-nginx-files.md)
|
||||
- [Connect To An RDS PostgreSQL Database](devops/connect-to-an-rds-postgresql-database.md)
|
||||
@@ -310,6 +310,7 @@ _1515 TILs and counting..._
|
||||
- [Find And Remove Files That Match A Name](git/find-and-remove-files-that-match-a-name.md)
|
||||
- [Find The Date That A File Was Added To The Repo](git/find-the-date-that-a-file-was-added-to-the-repo.md)
|
||||
- [Find The Initial Commit](git/find-the-initial-commit.md)
|
||||
- [Get Latest Commit Timestamp For A File](git/get-latest-commit-timestamp-for-a-file.md)
|
||||
- [Get The Name Of The Current Branch](git/get-the-name-of-the-current-branch.md)
|
||||
- [Get The Short Version Of The Latest Commit](git/get-the-short-version-of-the-latest-commit.md)
|
||||
- [Grab A Single File From A Stash](git/grab-a-single-file-from-a-stash.md)
|
||||
@@ -723,7 +724,7 @@ _1515 TILs and counting..._
|
||||
- [Check If Clusters Are Upgrade Compatible](postgres/check-if-clusters-are-upgrade-compatible.md)
|
||||
- [Check If The Local Server Is Running](postgres/check-if-the-local-server-is-running.md)
|
||||
- [Check If User Role Exists For Database](postgres/check-if-user-role-exists-for-database.md)
|
||||
- [Check Table For Any Oprhaned Records](postgres/check-table-for-any-orphaned-records.md)
|
||||
- [Check Table For Any Orphaned Records](postgres/check-table-for-any-orphaned-records.md)
|
||||
- [Checking Inequality](postgres/checking-inequality.md)
|
||||
- [Checking The Type Of A Value](postgres/checking-the-type-of-a-value.md)
|
||||
- [Clear The Screen In psql](postgres/clear-the-screen-in-psql.md)
|
||||
|
||||
25
git/get-latest-commit-timestamp-for-a-file.md
Normal file
25
git/get-latest-commit-timestamp-for-a-file.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# Get Latest Commit Timestamp For A File
|
||||
|
||||
The `git log` command can tell you all the commits that touched a file. That
|
||||
can be narrowed down to the latest commit for that file with the `-1` flag. The
|
||||
commit that it reports can then be further formatted to with the `--format`
|
||||
flag.
|
||||
|
||||
The `%ai` format pattern gives the date the commit was authored in an ISO
|
||||
8601-like format. The `%aI` (capital `I`) gives the date the commit was
|
||||
authored strictly in the ISO 8601 format.
|
||||
|
||||
Here are examples of both side by side:
|
||||
|
||||
```bash
|
||||
❯ git log -1 --format=%ai -- README.md
|
||||
2024-10-15 13:59:09 -0500
|
||||
|
||||
❯ git log -1 --format=%aI -- README.md
|
||||
2024-10-15T13:59:09-05:00
|
||||
```
|
||||
|
||||
I made use of this in a script where I needed to get an idea of when various
|
||||
files were most recently modified.
|
||||
|
||||
See `man git-log` and the `PRETTY FORMATS` section for more details.
|
||||
Reference in New Issue
Block a user