# 如何使用 SSH signing 提交 Git ## 教學開始 ### 01. ### 02. ### 03. ### 04. --- ## 常用指令 ### 一般 Git 指令 #### 拉取遠端 → 本機端 ``` git pull origin [branch_name] ``` #### 提交帶有簽名的 commit ``` git commit -m "your commit" -S ``` #### 推送本機端 → 遠端 ``` git push origin [branch_name] ``` ### 重新 Signing 指令 若在 commit 時忘記簽名,可以使用以下指令重新簽名 > 參數 "2" 代表:倒數第 2 個以前都會被重簽 ``` git rebase -S --signoff HEAD~2 ``` --- ## 常見問題 #### ■ 在配置 .git/config 時,顯示 error: unsupported value for gpg.format: ssh 因為 Git 版本要 2.34 以上才支援簽名,可以使用語法指令來確認當前的 Git 版本 ``` git --version ``` 如果顯示像是 git version 2.30.1 (Apple Git-130) 代表現在使用的是蘋果內建的 git,而非官方的版本! 可使用 Homebrew 來進行安裝 ``` brew install git ``` 並在安裝完後,將本地端的 Git 改為剛剛安裝的 Homebrew 版本 ``` export PATH=/usr/local/bin:$PATH ``` 參考: - https://stackoverflow.com/questions/74722894/error-unsupported-value-for-gpg-format-ssh - https://ajahne.github.io/blog/tools/2018/06/11/how-to-upgrade-git-mac.html #### ■ 如何在 commit 時選擇性的提交部分檔案或部分程式片段 可以使用 GUI 圖形化工具,如 Github desktop, Sourcetree...等來提交 Git。但因為目前 SSH signing 還是比較新的技術,僅有 Github desktop 支援,所以推薦先使用 Github desktop 來做提交! Download from: https://desktop.github.com/  #### ■ Warning: the ECDSA host key for 'github.com' differs from the key for the IP address '20.27.177.113' Offending key for IP in /Users/fay/.ssh/known_hosts:10 Matching host key in /Users/fay/.ssh/known_hosts:11 --- ## 參考資料 - [使用 SSH 簽名 Git 提交紀錄](https://taoshu.in/git/ssh-sign.html) - [Windows 上使用 SSH 簽名 Git 提交紀錄](https://dev.tobychung.com/signing-git-commits-with-ssh-keys)
×
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