(1)github上面新建仓库

本地项目上传github

(2)

  1. git init //初始化仓库

  2. git add .(文件name) //添加文件到本地仓库

  3. git commit -m “first commit” //添加文件描述信息

  4. git remote add origin + 远程仓库地址 //链接远程仓库,创建主分支

  5. git push -u origin master //把本地仓库的文件推送到远程仓库

本地项目上传github

最后一步出现上述问题

有如下几种解决方法:

1.使用强制push的方法:

$ git push -u origin master -f

这样会使远程修改丢失,一般是不可取的,尤其是多人协作开发的时候。

2.push前先将远程repository修改pull下来

$ git pull origin master

$ git push -u origin master

3.若不想merge远程和本地修改,可以先创建新的分支:

$ git branch [name]

然后push

$ git push -u origin [name]

本地项目上传github

相关文章:

  • 2021-05-13
  • 2022-12-23
  • 2021-07-19
  • 2021-05-11
  • 2021-08-01
猜你喜欢
  • 2021-11-05
  • 2021-08-01
  • 2021-10-26
  • 2021-09-14
  • 2021-06-18
相关资源
相似解决方案