# [筆記] Git / Gulp 相關設定問題集 ###### tags: `F2E`,`git`,`SSH`,`gulp` [TOC] --- ## 情境一:同台電腦想使用多組 GitHub 帳號,如何設定 SSH :::info **檢查是否有相關 SSH Key 存在** ```bash= $ ls -al ~/.ssh ``` ::: :::info **製作 SSH Key** ```bash= $ ssh-keygen -t rsa -b 4096 -C "your@email.com" ``` ::: :::info **已有 id_rsa,想再產生一組新的 SSH key** ```bash= ssh-keygen -t rsa -C "new@email.com" "id_rsa_new" # 以上寫法省略了 -f(指定檔名) # ssh-keygen -t rsa -C "new@email.com" -f "id_rsa_new" ``` 新產生的 rsa 私鑰與公鑰檔案會放在 git bash 正在執行的專案底下,記得把這兩個檔案,複製到 C:/user/使用者名稱/.ssh/ 資料夾底下。 ::: :::info **設定 SSH Key 密碼** ```bash= Enter passphrase (empty for no passphrase): 輸入密碼 Enter same passphrase again: 再輸入一次密碼 ``` ::: :::info **加入 SSH-Agent,確認啟動** ```bash= $ eval "$(ssh-agent -s)" ``` ::: :::info **將 SSH Key 加入 GitHub 帳號中** 複製 SSH Key 至剪貼簿 ```bash= $ clip < ~/.ssh/id_rsa.pub ``` 1. 至 GitHub 頁面中,點選右上頭像旁的倒三角形,點選 Settings 2. 在左側設定列表中點選 SSH and GPG keys 3. 選擇 New SSH key 4. Title 自行設定自己想要的名稱 5. 把前面複製的 SSH Key 貼到中間框框裡,最後選擇 Add SSH Key ::: :::info **測試 SSH Key 聯繫** ```bash= $ ssh -T git@github.com ``` ::: --- ### 想再新增一組 SSH 金鑰,還需要設定 git config :::info **開啟檔案編輯** ```bash= vim ~/.ssh/config ``` ::: :::info **填入設定內容** ```bash= Host github.com HostName github.com User git IdentityFile ~/.ssh/id_rsa Host github-new HostName github.com User git IdentityFile ~/.ssh/id_rsa_new ``` ::: :::info **進行驗證** ```bash= ssh -T github-new > Hi xiang-note! You've successfully authenticated, but GitHub does not provide shell access. ``` ::: :::info **修改現有 Repository 的遠端儲存庫** git remote set-url origin ....... ```bash= git remote set-url origin git@github-new:xiang-note/xiang-note.github.io.git ``` ::: :::info **查詢目前專案的遠端倉儲位址** ```bash= git remote -v ``` ::: > 參考資料: > * [製作 Git SSH 公開金鑰 For Windows](https://trunk-studio.com/blog/ssh-for-windows/) > * [同台電腦使用多組 GitHub 帳號](https://xnote.dev/multiple-ssh.html) <br> <br> ## 情境二:`gulp deploy` 時出現錯誤 TypeError: Cannot read property '0' of null :::info **進去 node_modules 中的 gulp-gh-pages 底下安裝 gift 套件** ```bash= cd node_modules/gulp-gh-pages/ npm install --save gift@0.10.2 cd ../../ gulp deploy ``` ::: <br> > 參考資料: > * [使用gulp-gh-pages出現錯誤TypeError: Cannot read property '0' of null解決方式](https://hfcode.blogspot.com/2019/01/gulp-gh-pages.html) <br> <br>
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up