For Windows

Tools Used:

after install git make file call.bat contains bash_git path and the shell_script file that we want to run it from windows using batch script

1cmd /c ""C:\Program Files\Git\bin\bash.exe" --login -i -- H:\myshell.sh"

after that goto obsidian workspace folder create file .gitignore

# To ignore files that could cause issues across different workspaces
nano .gitignore
# and set these 3 lines in
.obsidian/cache
.trash/
.DS_Store

then create file .gitattributes this file used to fix merge conflict automatically through keep both ours and theirs when conflict

# Add a line to .gitattributes:
*.md merge=union

initialize repo

1git init
2git add .
3git commit -m "init"
4git remote add origin https://github.com/USER/REPONAME.git
5# To permanently cache the credentials
6git config --global credential.helper store
7git push -u origin master

Task Scheduler make shell script file obsidian_git.sh

1# Making a new script to automate our repo management
2touch obsidian_git.sh 
3chmod +x obsidian_git.sh 

obsidian_git.sh

 1#!/usr/bin/env sh
 2VAULT_PATH="/f/7S/IS/ZNotes/My_Plan_2020/Courses_Note_Offline"
 3cd "$VAULT_PATH"
 4
 5# infinite loop repeat each 30 minutes 
 6while true 
 7do 
 8 # check internet connection before pull or push to avoit currupt script
 9 out=$(curl -Is https://www.google.com | head -1)
10 if echo "$out" | grep -q "200"; then
11 git pull > /dev/null 2>&1
12 CHANGES_EXIST="$(git status --porcelain | wc -l)"
13
14 # check if $CHANGES_EXIST Not equal to zero that means there is some changes on obsidian files
15 if [ "$CHANGES_EXIST" -ne 0 ]; then
16 
17 git pull > /dev/null 2>&1
18 git add . 
19 git commit -q -m "Last Sync: $(date +"%Y-%m-%d %H:%M:%S")" 
20 git push -q
21
22 fi
23
24 else
25 echo "Not Internet Connection..."
26 fi
27
28 sleep 30m
29
30done

To run script automatic when system startup and hidden cmd console, fist create vbs file run.vbs and set these lines in

Set WshShell = CreateObject("WScript.Shell") 
WshShell.Run chr(34) & "C:\Users\H\Documents\myObsidianWorkspace\call.bat" & Chr(34), 0
Set WshShell = Nothing

here should you change this path to your file path batch script file that we create on top section C:\Users\H\Documents\myObsidianWorkspace\call.bat

after that goto startup folder through shortcut keyboard Win+R to open run window type=> shell:startup automatic will open startup folder, last step copy run.vbs file there

every time system start the script will be run

For Android

Tools Used:

generate token authentication for github to login with it on android automatic without authentication each time

Settings > Developer settings > Personal access token

open termux then run this command to access storage termux-setup-storage clone your repo with token authentication cd storage/shared/ git clone https://token_name:token_key@github.com/username/my_workspace

change VAULT_Path in obsidian_git.sh with path your workspace in android in termux run command pwd to get current path then copy it and paste in obsidian_git.sh

to run script bash obsidian_git.sh will run automatic 😀 in background

for explore files and modify use obsidian app on android

that’s it everything done :)

References: