常见的github错误和处理

来源:互联网 发布:知乎lookfantastic 编辑:程序博客网 时间:2024/06/08 06:43

错误一:Updates were rejected because the tip of your current branch is behind

有如下几种解决方法:

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]
错误二:Pushing to git@git.oschina.net:summving/Python-Study-Note—2013.git
To git@git.oschina.net:summving/Python-Study-Note—2013.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to ‘git@git.oschina.net:summving/Python-Study-Note—2013.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 merge the remote changes (e.g.,
hint: ‘git pull’) before pushing again.
hint: See the ‘Note about fast-forwards’ in ‘git push –help’ for details。
解释的已经很清楚了。因为远程仓库比你的本地库更新,所以你得先 pull 下,再 push 就 ok 了。

原创粉丝点击