使用git上传代码至gitee

762 阅读1分钟

第一次使用git上传本地项目到gitee。

碰到了几点问题,也查了很多资料,最后终于完成了,记录一下。

步骤

1、在gitee上新建一个项目仓库,过程省略。

2、下载安装git。

git-scm.com/

3、安装后一些配置:

git config --global user.email "输入你注册码云的邮箱"

git config --global user.name "输入你码云的账户名"

4、项目上传步骤

  • 在git bash  输入 git init 初始化本地仓库

  • git add .      -- 将当前文件加入到仓库

  • git commit -m '添加此次更新的内容备注' 

  • git remote add origin  HTTPS链接

  • git pull --rebase origin master       --进行代码合并

  • git push -u origin master         --上传至远程仓库

遇到的报错

! [rejected] master         -> master (non-fast-forward) 

error: failed to push some refs to 'gitee.com/liang-zhich…' 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.

出现错误的主要原因是github中的README.md文件不在本地代码目录中。

可以通过代码合并来解决。