本地項目導入遠程git倉庫


在你自己項目的根目錄下執行如下命令
 1 //初始化git本地倉庫
 2 git init
 3 
 4 //添加文件到本地git倉庫
 5 git add .
 6 
 7 //提交文件到本地git倉庫
 8 git commit -m"初始導入"
 9 
10 //建立遠程倉庫鏈接
11 git remote add origin xxx.git
12 
13 //推送到遠程倉庫
14 git push origin master

如果在執行git push origin master過程中報錯如下:

1 hint: Updates were rejected because the remote contains work that you do
2 hint: not have locally. This is usually caused by another repository pushing
3 hint: to the same ref. You may want to first integrate the remote changes
4 hint: (e.g., 'git pull ...') before pushing again.
5 hint: See the 'Note about fast-forwards' in 'git push --help' for details.

則表示遠程倉庫代碼與本地倉庫代碼產生版本沖突,需要將遠程倉庫代碼pull到本地

1 //更新遠程代碼到本地倉庫
2 git pull origin master

完成上面步驟之后,就可以將本地代碼推送到遠程倉庫啦!

1 //推送到遠程倉庫
2 git push origin master

至此本地項目導入遠程倉庫完成~

附上git刪除遠程文件命令

1 git rm -rf --cached target/*

刪除完成之后,commit、push


免責聲明!

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



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