error: failed to push some refs to 'https://github.com/.....'

来源:互联网 发布:无锡市软件行业协会 编辑:程序博客网 时间:2024/06/15 06:31

执行: 

git push

出现:

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

error: failed to push some refs to 'https://github.com/.....'
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.

背景:

1、一般是在git上创建了一个仓库,想把自己已有的项目推到git上,在git add . 和git commit -m "xxx"后git push 失败

2、在尝试按照提示git pull时又出现

U       .gitignore
A       README.md
Pull is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>'
as appropriate to mark resolution, or use 'git commit -a'.
解决办法:

按照提示 fix them ,问题是怎么fix them。

1、你提示打开文件(是以项目的根目录为起始目录的)

U       .gitignore
A       README.md

2、你会看到里面会有<<<<<<和=======和>>>>>>>

其中<<<<<<<(七个小于号)和=======(七个等于号)之间的是当前分支的内容,=======(七个等于号)和>>>>>>>(七个大于号)之间的内容是合并的分支的内容。此时需要人工判断保留哪些内容,修改完成后,再将文件提交在暂存区(add操作),再commit到版本库就解决冲突了,然后就可以pull,最后就可以push了



其实整个过程就是要把你远程和本地的项目合并,开始的时候如下图:

master是本地分支master ;laisx/master是远程分支master(默认是origin/master)


搞完上面的一切就成了:



0 0
原创粉丝点击