git提交項目到已有庫

借鑑地址:https://blog.csdn.net/jerryhanjj/article/details/72777618

Git global setup
git config --global user.name "張衍濤"
git config --global user.email "[email protected]"

 

Create a new repository
git clone http://192.168.1.202:8060/guodun-online/online.git
cd online
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master

 上傳項目

跟蹤項目文件夾中的所有文件和文件夾

git add . 

輸入本次的提交說明,準備提交暫存區中的更改的已跟蹤文件,單引號內爲說明內容

git commit -m 'first_commit'

關聯遠程倉庫,添加後,遠程庫的名字就是 origin,這是 Git 默認的叫法,也可以改成別的,但是 origin 這個名字一看就知道是遠程庫。

git remote add origin https:xxxx.git

如果關聯出現錯誤 fatal: remote origin already exists,則執行下列語句再進行關聯

git remote rm origin

把本地庫的所有內容推送到遠程庫上

git push -u origin master

如果在推送時出現錯誤 error:failed to push som refs to.......,則執行下列語句

git pull origin master

將遠程倉庫 Github 上的文件拉下來合併之後重新推送上去

執行最後一個語句仍然報錯:

fatal: refusing to merge unrelated histories

通過以下語句修復(可能是新版git的問題):

git pull origin master --allow-unrelated-histories

 

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