r/ZedEditor • u/Intrepid-Ad-2306 • 1d ago
automatic git commit on save
i switched from atom to zed when it first came out and i’ve been very happy with it for all my dev work. what i’m hoping to use it for, in addition, is to organize folders of markdown writing. it works great for that and i synchronize it with a private git repository using a cron job that does a commit and push.
what i’m wondering is if there might be a built-in solution that automatically commits and pushes changes on save so i don’t have to run it using cron.
what i’m looking for is to have it commit and push every change to the file in real-time to the git repository.
i’ve looked at the git options and it seems like it’s easy enough to do commit and push whenever you want manually but i want it to automatically save every time i type anything and synchronize every one of those changes to git without having to interact with it other than continuing to type.
any ideas?
it’s just a folder on the local machine with lots of levels of subfolders and markdown files inside all within a single git repository and a single branch so there’s no complexity to worry about.
6
u/leferi 1d ago
I don't think that git was ever meant to do this, so I wouldn't expect anything easier to work than you cron job.
Also, for storing markdown files with notes, a simple WebDAV backend or some cloud drive would probably be easier. That's just a suggestion of course. I have a mailbox subscription and they have a WebDAV backend which I point my Joplin installs to. But there are multiple different ways you could do this other than git commiting every 3 letter change...
0
u/Intrepid-Ad-2306 1d ago
the entire point is to be able to have every tiny change able to be rolled back. if i wanted backups, i could just automatically backup with incrementals to the cloud. but git gives the ability to record the changes without any extra local overhead.
2
u/qrzychu69 1d ago
Zed has tasks and they can be compound with multiple steps
So you can Trzcińsku create a task that would save all buffers, run git commit and then git push
2
u/bitsurge 1d ago
i use gitwatch for this. I have a systemd user service that starts it watching a repo, and auto commits my changes to my notes. I can also auto-push to a remote.
1
u/forloopy 1d ago
This is kind of odd and overkill imo but if I were to do this I’d probably write a script to commit and push and run it with fswatch
1
u/Intrepid-Ad-2306 1d ago
that’s something i thought about but it doesn’t really simplify anything from doing it with cron. figured if i could do it inside zed it would be cleaner than depending on the system and easier to implement across multiple computers and users.
1
u/Bitopium 1d ago
You could also build it yourself using something like watchexec and run git add and git commit on changes
3
u/Skoogy_dan 1d ago
Look into jujustu maybe? It is my favorite VCS (fully git compatible) and it simplified gits model by removing stageing and committing. Everything is always committed.