Last active
October 7, 2022 18:36
-
-
Save ivanskodje/eb370b4ac612a95de36834ecebe57b99 to your computer and use it in GitHub Desktop.
Git Sync Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
# Purpose: For automating sync between Obsidian.md Vault and Git | |
# Modified script, not original work. Removed a lot of comments. | |
# | |
# You can find the original script here (thank you for making it): | |
# https://gist.githubusercontent.com/lucidhacker/0d6ea6308997921a5f810be10a48a498/raw/386fd5c640282daeaa3c9c5b7f4e875511c2946c/zk_sync.sh | |
# If you are using android+termux, | |
# replace the first line with this: #!/data/data/com.termux/files/usr/bin/bash | |
# If you are using android+termux, and you have run "termux-setup-storage" on termux to setup symlinks, | |
# the path structure looks something like: "/data/data/com.termux/files/storage/shared/documents/your-vault-here" | |
# CHANGE PATH | |
VAULT_PATH="/FULL/PATH/TO/YOUR/VAULT" | |
# Check for changes | |
cd "$VAULT_PATH" | |
git pull | |
CHANGES_EXIST="$(git status --porcelain | wc -l)" | |
if [ "$CHANGES_EXIST" -eq 0 ]; then | |
exit 0 | |
fi | |
# Perform Sync | |
git pull | |
git add . | |
git commit -q -m "Last Sync: $(date +"%Y-%m-%d %H:%M:%S")" | |
git push -q |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment