從服務器上拉代碼有如下報錯:
fatal: Not a git repository (or any of the parent directories): .git
初始代本地版本庫:
[root@NB gitdb]# git init Initialized empty Git repository in /data/gitdb/.git/
發生下面的報錯:
git pull git@xx.xxx.xx.xx:yanjing_chenl/IT-DOC.git ssh: connect to host xx.xx.xx.xx port 22: Connection timed out fatal: The remote end hung up unexpectedly
因為安全期間我改變了git服務器的端口為非22端口
ssh默認端口為22,而Git的訪問是基於ssh的。為了安全我們會更改服務的ssh端口號,即當ssh的端口不是22端口時,git訪問會出現:
ssh: connect to host xxx.com port 22: Connection timed out
無論客戶端是在windows還是linux,配置訪問的端口號,都是修改用戶的.ssh文件里的config文件
以linux為例:用戶root為例
/root/.ssh/config
config文件如果沒有,則建一個
config中添加如下內容:
#如果是以域名訪問的則添加如下內容: host xxx HostName xxx.com Port 3333 如果以ip訪問的,則添加如下內容: Host "12.123.xx.xx" Port 3333 如我的機器是如下配置 [root@NB ok]# cat ~/.ssh/config hostname x0.xx.xx.xx port xx0xx
問題解決
但還是有個很嚴重的問題,所有的ssh 加任何的ip都 會定向到 config文件里配的那個ip,也就是說所有的ssh都 會豋錄到這個ip的服務器上!!!!
這個問題可以這樣解決,只配置端口:
# cat ~/.ssh/config port 22022