本地连接git 服务器方式:以及git连接时报错
第一:下載git 客戶端
在客戶端下載安裝Git,在需要的地方打開? Git? Bash Here
?
第二:連接git服務器,下載代碼:
配置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? ? ? ? ?#克隆項目
?
?
輸入git 連接賬戶 和密碼:?
?
克隆下載成功:
?
第三,更新下載、上傳代碼
$ git pull #更新git服務器上最新代碼 # git add . #提交到緩存區 # git commit -m "add 修改購買金額" #提交到版本庫 # git push #上傳到git服務器?
第四,把本地源代碼文件夾上傳到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服務器
已存在的 Git 版本庫
上傳軟件項目到gitlab [root@node2 ~]# cd devops/ [root@node2 devops]# git remote rename origin old-origin出現以下錯誤,忽略即可 error: 不能重命名配置小節 '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?
?
?
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
一,報錯
git clone 或?git push的時候remote: HTTP Basic: Access denied? ? 報錯!!!
輸入賬號密碼,結果可能把用戶名輸成郵箱地址了,導致出錯了,但是就不能改了,一直提示這樣
把賬號和密碼輸錯了,就會提示這種錯誤。又不能修改。只能用Windows的 cmd :
git config --system --unset credential.helper
?
二, 報錯
遇到了題目所示的錯誤,簡單來說就是目標路徑‘.’已經存在并且不是一個空目錄。
可是在我在文件夾下并沒有看到任何文件,顯示“該文件夾為空”,然后自然而然地,我想到了這個'.'路徑是不是被Windows隱藏了?
于是我打開工具->文件夾選項->查看->顯示隱藏文件,終于發現了隱藏文件夾“.git”。
刪掉該文件夾后,再次執行git clone,成功拉下代碼。
?
三,遠程來源已經存在??
把git上clone 下載的代碼,用已存在的文件夾或 Git 倉庫? 的方式提交到 另外一個 git服務器上。報錯!!!
fatal: remote origin already exists?
譯文:
致命:遠程來源已經存在?
解決辦法:
$ git remote rename origin old-origin 移除遠程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 提交成功,完美解決?
總結
以上是生活随笔為你收集整理的本地连接git 服务器方式:以及git连接时报错的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 外网访问 KVM 虚拟机
- 下一篇: 物理主机安装linux的方法