使用github问题

在github上面创建完仓库,推送代码的时候,出错了,报错如下:

.           

网上搜索了下,是因为远程repository和我本地的repositor

y冲突导致的,而我在创建版本库后,在github的版本库页面点击了创建README.md文件的按钮创建了说明文档,但是却没有pull到本地。这样就产生了版本冲突的问题。

有如下几种解决方法:

1.使用强制push的方法:

$ git push -uorigin master -f

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

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

$ git pull--rebase  origin master

$ git push -uorigin master

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

$ git branch[name]

然后push

$ git push -uorigin [name]

我采用的第二种方式,先pull到本地放自己本地的代码和github上面一样,然后,再push代码到github。

Cause

This is caused by the repository still being empty. There are no commits in the repository and thus no master branch to push to the server.

Resolution

Create the first commit inside of the repository and then it can be pushed. For example, the following with create an initial commit and push it to the server.

touch initial
 
git add initial
 
git commit -m "initial commit"
 
git push -u origin master

github上传教程:https://blog.csdn.net/chenyufeng1991/article/details/48930471

猜你喜欢

转载自www.cnblogs.com/threestoneslee/p/9240698.html