本地连接git 服务器方式:以及git连接时报错
第一:下載git 客戶端
在客戶端下載安裝Git,在需要的地方打開? Git? Bash Here
?
第二:連接git服務(wù)器,下載代碼:
配置git:(在git bash 上配置)
$ git config --global user.name xxxxxx
$ git config --global user.email 765466931@qq.com
$ git config --list? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? #查看配置
$ git clone http://47.92.xx.xx/yct_app/cpw_center.git? ? ? ? ?#克隆項(xiàng)目
?
?
輸入git 連接賬戶 和密碼:?
?
克隆下載成功:
?
第三,更新下載、上傳代碼
$ git pull #更新git服務(wù)器上最新代碼 # git add . #提交到緩存區(qū) # git commit -m "add 修改購買金額" #提交到版本庫 # git push #上傳到git服務(wù)器?
第四,把本地源代碼文件夾上傳到git上
已存在的文件夾
cd existing_folder git init git remote add origin http://gitlab/root/ios-app.git git add . git commit -m "Initial commit" git push -u origin master?
第五,把本地的git版本庫上傳到git服務(wù)器
已存在的 Git 版本庫
上傳軟件項(xiàng)目到gitlab [root@node2 ~]# cd devops/ [root@node2 devops]# git remote rename origin old-origin出現(xiàn)以下錯(cuò)誤,忽略即可 error: 不能重命名配置小節(jié) 'remote.origin' 到 'remote.old-origin' [root@node2 devops]# git remote add origin http://192.168.4.1/devops/core_py.git [root@node2 devops]# git push -u origin --all [root@node2 devops]# git push -u origin --tags?
?
?
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
一,報(bào)錯(cuò)
git clone 或?git push的時(shí)候remote: HTTP Basic: Access denied? ? 報(bào)錯(cuò)!!!
輸入賬號密碼,結(jié)果可能把用戶名輸成郵箱地址了,導(dǎo)致出錯(cuò)了,但是就不能改了,一直提示這樣
把賬號和密碼輸錯(cuò)了,就會提示這種錯(cuò)誤。又不能修改。只能用Windows的 cmd :
git config --system --unset credential.helper
?
二, 報(bào)錯(cuò)
遇到了題目所示的錯(cuò)誤,簡單來說就是目標(biāo)路徑‘.’已經(jīng)存在并且不是一個(gè)空目錄。
可是在我在文件夾下并沒有看到任何文件,顯示“該文件夾為空”,然后自然而然地,我想到了這個(gè)'.'路徑是不是被Windows隱藏了?
于是我打開工具->文件夾選項(xiàng)->查看->顯示隱藏文件,終于發(fā)現(xiàn)了隱藏文件夾“.git”。
刪掉該文件夾后,再次執(zhí)行g(shù)it clone,成功拉下代碼。
?
三,遠(yuǎn)程來源已經(jīng)存在??
把git上clone 下載的代碼,用已存在的文件夾或 Git 倉庫? 的方式提交到 另外一個(gè) git服務(wù)器上。報(bào)錯(cuò)!!!
fatal: remote origin already exists?
譯文:
致命:遠(yuǎn)程來源已經(jīng)存在?
解決辦法:
$ git remote rename origin old-origin 移除遠(yuǎn)程git源$ git remote add origin https://code.aliyun.com/yct_app/cpw_app.git$ git add . $ $ git commit -m "java first"$ git push -u origin master 提交成功,完美解決?
總結(jié)
以上是生活随笔為你收集整理的本地连接git 服务器方式:以及git连接时报错的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 外网访问 KVM 虚拟机
- 下一篇: 物理主机安装linux的方法