使用git把本地目錄傳到遠程倉庫


需求:

要把本地不為空的一個目錄和遠程現有的一個倉庫關聯
步驟如下:

git init //生成.git目錄
git add . //把當前目錄里的文件加入到暫存區
git commit -m '上傳' //從暫存區提交到倉庫
git remote add origin 遠程倉庫地址 //添加遠程倉庫
git branch --set-upstream-to=origin/<branch> master //本地倉庫和遠程倉庫關聯,git pull時就會有提示
git status //會有信息顯示:Your branch is up-to-date with 'origin/master'.
不過一般遠程倉庫會和現有倉庫合並不了,單純的git pull會提示fatal: refusing to merge unrelated histories
git pull --rebase origin master //看來以rebase變基的方式可以合並啊
git push	 //提交到遠程倉庫

參考地址1


免責聲明!

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



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