本地文件夾關聯(添加)到git上

最近放假在家呆的有些廢了,今天在家上完班打算把過去一年寫的代碼都整理一下,結果又忘了怎麼把本地的文件夾上傳到git上了。好吧好吧,這回記錄下來,下次忘了再看吧。。。

1、在git上新建一個project

2、找到要上傳的文件夾路徑,右鍵空白處打開git bash

3、git初始化

$ git init

4、git remote add origin "自己在三方代碼託管平臺上所創建倉庫對應的地址"

$ git remote add origin [email protected]:thematic1/ocean-drawer.git

5、git add . 將本地工程文件夾所有內容添加至緩存區

& git add .

6、git commit - m "提交日誌"

7、git push -u origin master (首次推代碼至遠程倉庫)    

git push (非首次推代碼至遠程倉庫)

注意:有可能在第7步時會出現如下問題:

問題1:fatal: Authentication failed for "https://gitlab.com/thematic1/ocean-drawer.git/"

'解決方式:重新設置賬號相關git config --global user.name "你在碼雲上的用戶名"

git config --global user.email "你在碼雲上註冊賬戶時使用的郵箱"

問題2: error: failed to push some refs to "https://gitlab.com/thematic1/ocean-drawer.git/"

解決方式:git pull origin master

問題3:fatal: refusing to merge unrelated histories

解決方式:git pull origin master --allow-unrelated-histories
 

這樣就上傳成功了

 

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