1. 使用git客戶端
我下載的是這個https://git-for-windows.github.io/
打開shell客戶端勋颖,輸入git命令武福,如下所示淡诗。
huangzhihao@G8WFWB2 MINGW64 ~
$ git
usage: git [--version] [--help] [-C] [-c name=value]? ? ? ? ? [--exec-path[=]] [--html-path] [--man-path] [--info-path]? ? ? ? ? [-p | --paginate | --no-pager] [--no-replace-objects] [--bare]? ? ? ? ? [--git-dir=] [--work-tree=] [--namespace=][]
2.如何配置git選項
linux下git配置文件位于home目錄下, 文件名為.gitconfig覆旱。
對應的windows的配置文件位于C:\Users\huangzhihao目錄下蘸朋,后面那個是當前的用戶名。文件名也是.gitconfig.
3.sshkey的生成和添加
與linux上一樣扣唱。
4. 疑難問題
Unable to negotiate with 10.140.70.24 port 29418: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1
這個問題在linux下的解決方式是修改ssh的配置文件藕坯,該文件路徑為~/.ssh/config.
打開文件后類似如下所示团南,在hostname后面添加KexAlgorithms +diffie-hellman-group1-sha1,重新連接后成功。
Host 10.120.0.70
??? Hostname 10.120.0.70
??? KexAlgorithms +diffie-hellman-group1-sha1
參照這個思路炼彪,嘗試修改windows對應目錄下的配置文件吐根。windows中ssh的文件夾路徑為C:\Users\huangzhihao\.ssh\。打開后發(fā)現(xiàn)沒有config文件辐马,添加一個config文件并添加如上的內容后拷橘,發(fā)現(xiàn)沒有效果。
應該是配置方式不對喜爷,參考http://stackoverflow.com/questions/7772190/passing-ssh-options-to-git-clone所說冗疮,配置全局命令可以輸入類似命令
git config --global core.sshCommand ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no
參照這個后,輸入命令行
git config --global core.sshcommand ssh -o KexAlgorithms=+diffie-hellman-group1-sha1
下面給出了git的help提示檩帐,應該是命令格式有誤术幔。加上雙引號,再試一次湃密。
git config --global core.sshcommand "ssh -o KexAlgorithms=+diffie-hellman-group1-sha1"
沒有錯誤提示特愿,然后重新調用git clone命令,git clone ssh://huangzhihao@xxx.devops.xxx.com:29418/project/path/
連接成功勾缭!
再次打開C:\Users\huangzhihao\.gitconfig, 我們會發(fā)現(xiàn)增加了如下內容
[core]
??? sshcommand = ssh -o KexAlgorithms=+diffie-hellman-group1-sha1
所以,也可以直接在.gitconfig文件中按照以上格式來添加配置選項目养。
git配置選項可以參考https://git-scm.com/docs/git-config