On Mon, Aug 21, 2023 at 11:01:21PM -0400, Russell L. Harris wrote: > I write articles for publication. I typically spend anywhere from > several hours to many days on each article. It is frustrating to work > for an hour or two on a paragraph or a page and then accidentally to > erase what I have written.
Heard that. > The second repository is my backup; it resides on another machine. > Several times a day, I SSH into the backup machine and pull the > working repository. It would be nice to be able to push from WORKING > to BACKUP, eliminating the need to SSH. I'd set up a post-commit hook on the production system. Have it SSH to your backup system and do a pull automatically whenever you commit a change. I made an example project to try it: me% mkdir example me% cd example me% git init Test file: me% date > testing me% git add testing me% git commit -m 'Testing a new file" me% git log d5fe2ce 2023-08-22 00:09:21 -0400 vogelke - Testing a new file Here's a test script to connect from my backup system ("bkup") and simulate pulling my working repo. I have an SSH public/private key set up for passwordless login: me% cat try #!/bin/sh export PATH=/usr/local/bin:/bin:/usr/bin ssh -q -c aes128-...@openssh.com -i $HOME/.ssh/bkup_ed25519 \ bkup "logger -t autopull git pull whatever" exit 0 Here's the remote system log when I run this from the command line: me@bkup% tail -1 /var/log/messages Aug 22 00:24:44 bkup autopull[60592]: git pull whatever I copied the test script ("try") to .git/hooks/post-commit and ran a commit: me% git add try me% date; git commit -m 'Added hook' Tue Aug 22 00:31:27 EDT 2023 [master 42cb917] Added hook 1 file changed, 6 insertions(+) create mode 100755 try me% git log 42cb917 2023-08-22 00:31:27 -0400 vogelke - Added hook d5fe2ce 2023-08-22 00:09:21 -0400 vogelke - Testing a new file Here's the system log on the remote system showing my hook ran when the commit was done: me@bkup% tail -1 /var/log/messages Aug 22 00:31:27 bkup autopull[80162]: git pull whatever Replace the "logger ..." part of post-commit to run "git pull" or whatever. Hope this helps. -- Karl Vogel I don't speak for the USAF or my company There's no kill like overkill. --Reddit post about using .45 ACP rounds to dispose of old disk drives