# GitHub for Logseq in Windows ## Create the rep on Github 進到 [Github](https://github.com/) 首頁,登入或註冊 ![github-1](https://i.imgur.com/jJm1SHN.jpg) 點選 "New" 以新增 "Repository"(資料庫) ![github-2](https://i.imgur.com/kRzE0ix.png) 填寫資料庫名稱、選擇權限(公開或私人),然後點選建立資料庫 若為個人使用建議點選 "Private" ![github-3-1](https://i.imgur.com/YftQKqs.png) ![github-3-2](https://i.imgur.com/QPRSXGd.png) 看到下列頁面表示建立成功,若於前一步驟勾選 "add README.md" 則不會出現下列程式碼 ``` echo "# test-for-logseq" >> README.md git init git add README.md git commit -m "first commit" git branch -M main git remote add origin https://github.com/changanlee/test-for-logseq.git git push -u origin main ``` ![github-4-1](https://i.imgur.com/xiKXdCY.png) ## Set up 1^st^ computer 安裝 [Git](https://git-scm.com/) 到電腦上 ![github-5-1](https://i.imgur.com/EQrTZPF.png) 在 "電腦1" 建立新資料夾,以作為該電腦 Logseq 的本機資料庫,範例以 "test-for-logseq-local" 為例 ![github-5-2](https://i.imgur.com/yu7HJ9y.jpg) ### 初次使用 Git 搜尋 "cmd" 並打開 ![github-6-1](https://i.imgur.com/R01KZsN.png) ![github-6-2](https://i.imgur.com/F5lzwqW.png) 進入 test-for-logseq-local 資料夾,於終端機輸入以下程式碼,資料夾位置可以點選上方欄取得,確認是否在先前的 "C:\Users\user" 後多了 "\Desktop\test-for-logseq-local" ``` cd C:\Users\user\Desktop\test-for-logseq-local ``` ![github-6-3](https://i.imgur.com/3WBFGlU.png) 使用 GitHub 上面的程式碼,將 "# test-for-logseq"寫入 "READ.md" 中,並添加至資料夾中 ``` echo "# test-for-logseq" >> README.md ``` ![github-6-4](https://i.imgur.com/QsXPSrt.png) 初始化,確認是否有 ".git" 資料夾,預設為隱藏 ![github-6-5](https://i.imgur.com/jXOe6J6.png) 若沒看到則點選資料夾上方 "檢視" → 勾選 "隱藏項目" ![github-6-6](https://i.imgur.com/13f3BWV.png) 依序輸入程式碼,將 "README.md" 上傳至 GitHub 資料庫 ``` git add README.md git commit -m "first commit" git branch -M main git remote add origin https://github.com/changanlee/test-for-logseq.git git push -u origin main ``` ![github-6-7](https://i.imgur.com/XejttkL.png) 其中 "git remote" 的路徑可由 GitHub 資料庫網頁上取得 ![github-6-8](https://i.imgur.com/iU0nxhC.png) 完成後可點選 "重新整理圖示" 或 "<> Code" 來檢視是否上傳成功 ![github-6-9](https://i.imgur.com/fDQlhdM.png) ### 連結 Logseq 打開 Logseq 點選左上資料庫,新增 Graph ![github-7-1](https://i.imgur.com/OZeEjDj.png) 選擇 test-for-logseq-local 資料夾 ![github-7-2](https://i.imgur.com/mx4vSIu.png) 在 Journals (日記) 輸入測試文字 "test 123" ![github-7-3](https://i.imgur.com/02AoteO.png) 使用 cmd 將筆記上傳至 GitHub 資料庫 ``` git push ``` 重新整理 GitHub 資料庫頁面,並點進 "journals" 資料夾中 ![github-7-4](https://i.imgur.com/8bas6yc.png) ![github-7-5](https://i.imgur.com/mxBZSGn.png) 點選檔案 "2022_12_11.md" (因檔案於2022-12-11建立測試,實際情況將依個人建立時間為準) ![github-7-6](https://i.imgur.com/ZB52FjB.png) 看到 "test 123"內容表示成功,點擊修改內容 ![github-7-7](https://i.imgur.com/uJedbCB.png) 將內容修改為 "test 123 + 456",並保存修改 ![github-7-8](https://i.imgur.com/kZ45Y21.png) ![github-7-9](https://i.imgur.com/M31P91m.png) 確認內容修改為 "test 123 + 456" ![github-7-10](https://i.imgur.com/ul5GCtd.png) 使用 cmd 將資料從 GitHub 資料庫下載至 "電腦1" 的 test-for-logseq-local 資料夾中 ``` git pull ``` ![github-7-11](https://i.imgur.com/V2RHXH9.png) 確認 Logseq 內容更新完成 ![github-7-12](https://i.imgur.com/PkIbiGC.png) ## Setup 2nd and other computers 建立Logseq資料夾在第2台電腦上 (範例為建立test-for-logseq-2nd於桌面上) ![2nd computer sync up-1](https://i.imgur.com/ad2QOo4.jpg) 開啟 Git Bash ![2nd computer sync up-2](https://i.imgur.com/kj24NKF.jpg) 輸入程式碼建立ssh金鑰 ``` ssh-keygen -t rsa -C "您的GitHub信箱" ``` ![2nd computer sync up-3](https://i.imgur.com/KNDs21K.png) 把金鑰放入agent中以便管理 ``` eval "ssh-agent -s" ``` ![2nd computer sync up-4](https://i.imgur.com/nctE8bi.png) 把金鑰加入至 "id_rsa" 檔案中,可能會顯示錯誤題示 "could not open a connection to your authentication agent" ``` ssh-add ~/.ssh/id_rsa ``` ![2nd computer sync up-5](https://i.imgur.com/6nh8CTW.png) 輸入下列程式碼排除錯誤後,再重新把金鑰加入檔案。 ``` ssh-agent bash ssh-add ~/.ssh/id_rsa ``` ![2nd computer sync up-6](https://i.imgur.com/majc51H.png) 獲取金鑰方法1:使用 vim打開檔案,按右鍵進行複製 ``` vim ~/.ssh/id_rsa.pub ``` ![2nd computer sync up-7-1](https://i.imgur.com/3cqnIsf.png) 獲取金鑰方法2:進入 ".ssh" 資料夾中(路徑預設在 C:\使用者),找到 "id_rsa.pub"並用記事本打開,即可複製金鑰 ![2nd computer sync up-7-2](https://i.imgur.com/HbAPfUa.png) 打開GitHub並進入設定頁面 ![2nd computer sync up-8](https://i.imgur.com/sIYul5M.png) 進入 "SSH and GPG keys" 後點選 " New ssh key" 添加新金鑰 ![2nd computer sync up-9](https://i.imgur.com/NS1K0hb.png) 將名稱輸入於 "Title" , 並加金鑰貼至於下方欄後新增 ![2nd computer sync up-10](https://i.imgur.com/ITKj6Hw.png) 透過 cmd 進入 新裝置的 Logseq 資料夾 ``` cd "Logseq 資料夾路徑" ``` ![2nd computer sync up-11](https://i.imgur.com/HC21J6S.png) 初始化資料夾環境 ``` git init ``` ![2nd computer sync up-12](https://i.imgur.com/I0aD74x.png) 從GitHub資料庫頁面,複製資料庫連結 ![2nd computer sync up-13](https://i.imgur.com/UlUYXJH.png) 從Github複製資料庫到新電腦中 ``` git clone "資料庫連結" ``` ![2nd computer sync up-14](https://i.imgur.com/30UqvSA.png) 打開 Logseq 連結下載後的資料庫確認 ![2nd computer sync up-15](https://i.imgur.com/6Utu9x1.png)