work_sript/05.auto_work/obisidian_sync.bat

22 lines
480 B
Batchfile
Raw Normal View History

2024-09-01 23:12:18 +08:00
@echo off
::配置Obsidian workspace地址
set obsidian_path="D:\note\Marcin_OB_Repo"
::切换目录到 Obsidian workspace下
cd %obsidian_path%
::先拉取远端更新
git pull
::判断是否有更新并将更新同步到远端仓库
for /f "delims=" %%a in ('git status --porcelain') do (
set HAS_CHANGES=1
goto end_loop
)
:end_loop
if defined HAS_CHANGES (
git add -A
git commit -m "Daily Sync"
git push origin main
) else (
echo Git has no changes.
)