文章目录
一、创建码云仓库
- 根据需要在码云上创建仓库
- 进入自己的项目
- 创建README.md【mac系统的话
touch README.md
】 - 创建.gitignore将不需要上传的文件屏蔽掉
- 使用
git status
查看提交文件,是否是你想提交的内容
- 使用
git add .
添加所有的变更文件
- 使用
git commit -am 'first commit init project'
提交并且添加注释。注意这个时候只是提交到本地仓库中,还不在码云的远程仓库。
- 使用
git remote add origin git@gitee.com:520yd/mmall.git
链接远程地址,这个远程地址也可以是HTTPS的,只是授权方式不同而已。
- 使用
git branch
查看当前分支。 - 使用
git push -u origin master
将本地仓库提交到远程。- 问题一:
解决方案:使用To gitee.com:520yd/mmall.git ! [rejected] master -> master (fetch first) error: failed to push some refs to 'git@gitee.com:520yd/mmall.git' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes hint: (e.g., 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.
git pull
重新拉取下。再次使用git push -u origin master
- 问题二:
解决方案:使用To gitee.com:520yd/mmall.git ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'git@gitee.com:520yd/mmall.git' hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.
git push -u -f origin master
强制覆盖版本提交,因为是第一次提交,可以如此操作。
- 创建README.md【mac系统的话