Image may be NSFW.
Clik here to view.
我一直使用Dropbox來同步Obsidian的筆記,但因為使用的是Dropbox Basic方案,有使用設備的限制,因此在Android手機上是使用DropSync App來同步筆記檔案。但看到Obsidian Git外掛已經很穩定,且行動設備(Android、iOS與iPad)也能在不安裝Git本地端的狀況下直接存取Git repository,因此開始將儲存放由雲端硬碟變更為Git client。以是針對不同使用狀況下的操作步驟。
- 從零開始:在Sandbox裡建立Git與Obsidian的系統與儲存庫
- 現有筆記儲存庫加上Git環境以同步到GitHub
- 行動設備安裝使用Git外掛的Obsidian
- 其他Git操作,如 .gitignore 添加不同步資料夾或檔案
遠端使用的是GitHub。
[!tip] 通訊協定:https
行動設備使用Git外掛時:遠端網址的通訊協定必須使用 HTTPS,而不要使用SSH
1. 從零開始
1.1. GitHub設定
- 建立GitHub帳號
- 點擊頭像→【Settings】→左側最後一項【Developer Settings】→【Tokens (classic)】→【Generate new token】【Generate new token (classic)】
- 依序輸入資料,勾選repo欄位,點擊最下方的【Generate token】
- 期限:預設是30天,可改為無期限
- 複製產生出的Access token,並保存到密碼管理工具裡
Image may be NSFW.
Clik here to view.
▼ 使用 [Fine-grained token]([[github/settings/personal-access-tokens]] Image may be NSFW.
Clik here to view. 時要將Contents的存取改成讀寫皆可
Image may be NSFW.
Clik here to view.
- 點擊右上角的【+】號→點擊【New repository】以建立Git儲存庫,命名並勾選為私用(Private)→【Create repository】
Image may be NSFW.
Clik here to view.
-
點選HTTPS,並複製網址到剪貼簿,網址格式是:[[github/%E5%B8%B3%E8%99%9F/%E5%BA%AB%E5%90%8D.git]] Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view. -
點擊步驟6 HTTPS下方的creating a new file,輸入任意內容後按【Commit changes...】
Image may be NSFW.
Clik here to view.
1.2. Sandbox操作
[!tip] Windows/macOS Git Client安裝參考
- Windows [obsidian-git-tut-windows]([[github/gitobsidiantutorial/obsidian-git-tut-windows]] Image may be NSFW.
Clik here to view.(逐步圖示)
- macOS: Git on macOS
-
下載並安裝[Git client](Git - Downloads),Windows預設會安裝到
C:\Program Files\Git
,路徑會加入PATH環境變數。皆使用預設值即可 -
下載並安裝Obsidian
-
啟動Obsidian後,建立啟始儲存庫:Create→Vault name輸入
notes
,Location選用C:\
,則儲存庫資料夾是C:\notes\
-
在Obsidian裡點擊左側邊的齒輪【Settings】→【Community plugins】→【Turn on community plugins】→【Browse】→搜尋Git→找到Git後按【Install】→【Enable】
-
按 Ctrl/Cmd+P在命令面板裡輸入clone,執行Git: Clone an existing remote repository
-
貼入步驟1.1複製的GitHub網址後按Enter
-
輸入儲存庫資料夾
personal-notes
後按Enter,Git外掛預設在現有儲存庫資料夾建立子目錄(即C:\notes\personal-notes\
) -
輸入需要的儲存庫深度,按Enter即可
-
彈出連線至GitHub對話窗,點擊Token,再貼入步驟1.1複製的Personal Access Token後按【Sign in】
-
Clone成功後重啟Obsidian
Image may be NSFW.
Clik here to view. -
在左下角點擊儲存庫清單→【Manage vaults...】→Open,選用
C:\notes\personal-notes
,使用Git控管的筆記儲存庫
Image may be NSFW.
Clik here to view. -
點擊左側邊的齒輪【Settings】→【Community plugins】→【Turn on community plugins】→【Browse】→搜尋Git→找到Git後按【Install】→【Enable】→【Options】
- Auto commit-and-sync interval (minutes):預設是 0 可改成想要同步的間隔分鐘數,如30
- 往下找到Author name for commit與Author email for commit,輸入GitHub的帳號名稱與Email
-
左側邊工具欄裡會出現【Open Git source control】圖示,點擊後右側邊欄會出現Git資訊面板
-
本地的修改在自動同步間隔時間內會自動同步,或在Git面板上方按 pull 接取GitHub上的檔案,或按 push 將本地新增或修改的內容推至GitHub
Image may be NSFW.
Clik here to view.
2. 已有儲存庫加上Git控管
-
重新啟動cmd.exe
-
在命令提示字元或終端機裡依序執行下列指令
git init git add README.md git commit -m "first commit" git branch -M main git remote add origin [[github/%E5%B8%B3%E8%99%9F/%E5%BA%AB%E5%90%8D.git]] [🔗](https://github.com/%E5%B8%B3%E8%99%9F/%E5%BA%AB%E5%90%8D.git) git push -u origin main
-
啟動Obsidian,後續同步驟1.2 第12點之後操作
3. 行動設備安裝Obsidian
- 用USB線連接電腦與行動設備,啟用檔案傳輸
- 將電腦裡的筆記儲存庫資料夾複製到行動設備的根目錄
- 安裝Obsidian,啟動Obsidian,開啟上一步驟的儲存庫資料夾
- 開啟命令面板執行Git pull測試
2025/3/17 ViscousPot/GitSync: Android mobile git client for syncing a repository between remote and a local directory]] Image may be NSFW.
Clik here to view.)
4. 可能遇見的問題
4.1. Windows: Obsidian隔段時間就彈出Username、Password的輸入prompt
除錯步驟:
- 輸入下列命令確認Git Credential Manager有正確設定
git config credential.helper
若未回傳 manager,建議重新安裝[Git client](Git - Downloading Package)最新版
[!tip] 參考
Installation - Git Documentation - Obsidian Publish
4.2. Windows: 出現帳號取存權限問題
試著將筆記儲存庫資料夾加入安全目錄:
git config --global --add safe.directory 你的儲存庫資料夾
5. Image may be NSFW.
Clik here to view.
相關鏈接
Image may be NSFW.
Clik here to view. 解說文章:
Image may be NSFW.
Clik here to view. obsidian-git GitHub: https://github.com/Vinzent03/obsidian-git
Image may be NSFW.
Clik here to view. 參考 Getting started with Git: https://docs.github.com/en/get-started/learning-to-code/getting-started-with-git
Image may be NSFW.
Clik here to view. git-changelog GitHub: https://github.com/shumadrid/obsidian-git-changelog
Image may be NSFW.
Clik here to view. 另一個Git外掛,不必安裝Git client: github-gitless-sync GitHub: https://github.com/silvanocerza/github-gitless-sync
6. 教學影片
##
您可能也會有興趣的類似文章
- [Obs#110] 用Emo Uploader將GitHub用做圖床,方便發佈、分享 (0則留言, 2022/12/27)
- Obs176|Obsidian的卡片顯示外掛:Notes Explorer、GridExplorer與Data Cards,視覺化筆記新體驗 (0則留言, 2025/03/30)
- Obs153|快速開啟外掛設定的方法;使用Open Plugin Settings與Advanced URI,透過Templater Hotkeys綁定快捷鍵 (0則留言, 2024/02/28)
- Obs146|Obsidian彙總常用說明網站的助手:HelpMate (0則留言, 2023/12/03)
- [Obs#88] 綜合練習:快速設定的6種方法─使用8個Obsidian外掛 (0則留言, 2022/05/21)
- Obs170|Obsidian的官方網頁擷取工具:Obsidian Web Clipper;設定與使用 (0則留言, 2024/11/24)
- Obs160|Obsidian試算表外掛2024年新選擇:Univer、Sheet Plus (2則留言, 2024/06/30)
- Obs126|Obsidian 2023/04 7個新外掛介紹與評析 (0則留言, 2023/04/29)
- [Obs-74] 和外掛相關的外掛─BRAT: 搶先體驗未上架外掛;Settings Search: 加速搜尋外掛設定 (0則留言, 2022/03/05)
- Obs151|幫Obsidian加上音樂-生產力火速大漲十倍!Image may be NSFW.
Clik here to view.使用Soundscapes外掛 (0則留言, 2024/02/08)
- Obs168|建立From Template模板命令的功能表,快速選取要使用的筆記模板 (0則留言, 2024/09/11)
- Obs164|將一篇英文文章製作成Anki閃卡的步驟,使用Yanki、ChatGPT(Copilot)與Note Splitter (0則留言, 2024/08/17)
- Obs166|捲土重來的Obsidian Note From Template終於修正小瑕疪而能正確運行了!推薦使用! (0則留言, 2024/08/25)
- Obs#117 | Obsidian表格攻略與表格就地編輯外掛:Table Enhancer (0則留言, 2023/03/19)
- Obs169|功能更強大的分頁顯示外掛:Obsidian Tabs與Tab Panels外掛 (0則留言, 2024/11/09)