git提交項目到已有庫


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

Git global setup
git config --global user.name "張衍濤"
git config --global user.email "xxxxx@qq.com"

 

Create a new repository
git clone http://ip:port/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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM