Sync Obsidian with Github

先備知識

Linux and Mac OS X

  1. 安裝 git

    Mac OS X (透過 Homebrew)

    1
    
    brew install git
    

    Linux (Debian/Ubuntu)

    1
    
    sudo apt-get install git
    
  2. Clone the repository

    進入存放repositoryfolder

    1
    
    cd ~/repositories
    

    clone

    1
    
    git clone https://github.com/{your_username}/{your_repository}
    
  3. Obsidian開啟vault,並選則該repository

Android

  1. 安裝Termux

    Google Play

  2. 更新pkg資料庫 && 升級已安裝軟體

    pkg update && pkg upgrade -y
    
  3. 安裝git的client端

    pkg install git
    
  4. Termux訪問儲存空間的權限

    termux-setup-storage
    
  5. 進入shared目錄

    cd /storage/shared
    
  6. 創建Obsidian使用的目錄並進入

    mkdir obsidian
    cd obsidian
    
  7. Clone the repository

    因為在 android手機上打字不那麼方便,我會將token存在~/.git-credentials.下次git pull就不用再輸入一次.

    注意 : ~/.git-credentials 會以明文儲存,確保你沒有給你的 token 太大的權限

    git config --global credential.helper store
    

    git clone

    git clone https://github.com/{your_username}/{your_repository}
    

    Push && Pull

    因為已經儲存github token了,pullpush時不用再輸入一次usernamepassword

    git pull
    

    Push

    git push
    
  8. Obsidian開啟vault