本地项目导入远程git仓库
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了本地项目导入远程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仓库的主要内容,如果未能解决你的问题,请参考以下文章