You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.
I just wanted to post a quick alternative to git-auto using a git post-commit hook and some gotchas I ran into while getting this set up. I like this approach because it ensures every commit is immediately pushed.
Creating post-commit hook
Ensure your logseq database is a git repository. This usually entails running git init in the root of the logseq directory.
Check "Enable Git auto commit" in the Logseq version control settings.
Create the file .git/hooks/post-commit relative to the root of the logseq repository with the following contents:
#!/bin/bash
git push
Potential Gotchas
On macOS, I usually use the osxkeychain for authentication using a "personal access token". This, for some reason didn't work out well and kept giving me the following error: fatal: could not read Username for 'https://github.com': Device not configured. I ensured that the script was being run as personal account, not root, but this didn't fix the issue. The easiest solution was to switch to using the git-credential-manager (GCM).
# check if current credential.helper is osxkeychain
❯ git config credential.helper
osxkeychain
# clear osxkeychain password
❯ git credential-osxkeychain erase
host=github.com
protocol=https
> [Press Return]
# install latest git and git credential manager (GCM) from homebrew
❯ brew install git
❯ brew tap microsoft/git
❯ brew install --cask git-credential-manager-core
# verify cask installation has automatically updated the credential.helper
❯ git config credential.helper
/usr/local/share/gcm-core/git-credential-manager-core
# attempt to git push, will bring up a pop-up establishing authentication
git push
For some reason, I was unable to change the hashbang for the post-commit hook. It seems to always use the system bash installed at /bin/bash (for me, version 3.2.57) even if I explicitly changed the hashbang to homebrew installed bash via #!/opt/homebrew/bin/bash. This means you can't use newer bash features like mycmd &>> /tmp/mylog etc.
This longer script helped me debug all of these issues:
I just wanted to post a quick alternative to
git-auto
using a gitpost-commit
hook and some gotchas I ran into while getting this set up. I like this approach because it ensures every commit is immediately pushed.Creating
post-commit
hookgit init
in the root of the logseq directory..git/hooks/post-commit
relative to the root of the logseq repository with the following contents:#!/bin/bash git push
Potential Gotchas
On macOS, I usually use the
osxkeychain
for authentication using a "personal access token". This, for some reason didn't work out well and kept giving me the following error:fatal: could not read Username for 'https://github.com': Device not configured
. I ensured that the script was being run as personal account, notroot
, but this didn't fix the issue. The easiest solution was to switch to using thegit-credential-manager
(GCM).For some reason, I was unable to change the hashbang for the post-commit hook. It seems to always use the system bash installed at
/bin/bash
(for me, version 3.2.57) even if I explicitly changed the hashbang to homebrew installed bash via#!/opt/homebrew/bin/bash
. This means you can't use newer bash features likemycmd &>> /tmp/mylog
etc.This longer script helped me debug all of these issues:
Hope this helps!
The text was updated successfully, but these errors were encountered: