本地项目导入远程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