码迷,mamicode.com
首页 > 其他好文 > 详细

本地项目导入远程git仓库

时间:2016-06-21 15:19:42      阅读:218      评论:0      收藏:0      [点我收藏+]

标签:

在你自己项目的根目录下执行如下命令
 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仓库

标签:

原文地址:http://www.cnblogs.com/thierry/p/5603554.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!