一、创建码云仓库
  • 根据需要在码云上创建仓库
  • 进入自己的项目
    • 创建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 强制覆盖版本提交,因为是第一次提交,可以如此操作。
Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐