git clone 他人的項目並git push 到自己的gitlab

github地址上通過git clone下載下來,而又想git push到我們自己的github

1 gitlab中新建項目

2 將git clone 的項目解壓到某文件夾

3 進入解壓文件夾,右鍵打開git bash

git config --global user.name "Shi"
git config --global user.email "[email protected]"
git init
git remote add origin http://*.*.*.*/shi/django-ex.git
git add .
git commit -m "Initial commit"
git push -u origin master

注: 執行上述命令會報錯

The file will have its original line endings in your working directory

解決方案:

我們從別人github地址上通過git clone下載下來,而又想git push到我們自己的github上,那麼就會出現上面提示的錯誤信息

此時需要執行如下代碼:

    git rm -r --cached .
    git config core.autocrlf false

    git add .

. 代表當前目錄
再重新執行:

git commit -m "Initial commit"

git push -u origin master

即可成功。

當gitlab密碼輸入錯誤時,報錯:git remote: HTTP Basic: Access denied 

解決辦法:

原因:本地git配置的用戶名、密碼與gitlabs上註冊的用戶名、密碼不一致。


解決方案:
1. 如果賬號密碼有變動 用這個命令 git config –system –unset credential.helper 重新輸入賬號密碼 應該就能解決了
2. 如果用了第一個命令 還不能解決問題那麼 用這個命令:
git config –global http.emptyAuth true
3.如果以上兩個方法不起作用,那麼採用以下方法:

進入控制面板》用戶賬號》憑據管理器?windows憑據》普通憑據,在裏面找到git,點開編輯密碼,更新爲最新密碼之後就可以正常操作了。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章