From Claude
Summary: Auto-updating Modified Dates in Obsidian with Git
We set up a git pre-commit hook that automatically updates the modified: date in your Obsidian notes’ frontmatter whenever you commit changes.
What we did:
- Identified your setup: Quartz repo at
Projects/quartzwith your Obsidian vault in thecontent/subfolder - Created a git hook at
.git/hooks/pre-committhat:- Runs automatically before each commit
- Finds all staged
.mdfiles in yourcontent/folder - Checks if they have a
modified:field in frontmatter - Updates it to the current timestamp (ISO format)
- Re-stages the files so the update is included in the commit
- Debugged syntax issues: Fixed grep regex and line break problems
- Ignored content/templates folder: Added
grep -v '^content/templates/'to file - Made it executable:
chmod +x .git/hooks/pre-commit
Result:
Now every time you git commit, your modified: dates automatically update to reflect when you actually committed the changes - no manual work needed! Files without the modified: field are left untouched.
You kept published: as manual so you control when something is truly “published” vs just updated.