git拒绝推送非快进 [英] git rejected push non-fast-forward

查看:328
本文介绍了git拒绝推送非快进的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对git很陌生,在过去的2个月里我一直在做一个小型项目,并且一直在向没有任何问题的bitbucket上推进。几天前,我压缩了我的项目文件夹(因为我不得不重新安装我的Linux操作系统),现在在重新安装Linux操作系统后解压缩。

所以,现在,我去了我的项目文件夹,继续愉快地工作,并最终做到:

  git add -A&& git commit -m修改后的代码&& git push origin master 

..这就是我通常所做的事情。



我得到:

 到https://johnsproject@bitbucket.org/johnsproject/proj .git 
! [被拒绝] master - >主(非快进)
错误:无法将某些参考推送到'https://johnsproject@bitbucket.org/johnsproject/proj.git'
提示:更新被拒绝,因为您当前的分支在
提示后面:它的远程对应部分。合并远程更改(例如'git pull')
提示:再次按下之前。
提示:有关详细信息,请参阅'git push --help'中的'关于快速转发的注意事项'。

我看过几个SO问题,他们建议使用强制标记 -f - 但我不确定是否应该这样做。



ps:我在主分支上 -

如果有人能指出我在这里的正确方向,我将非常感激。



谢谢。

解决方案

你必须拉动才能推动。
Do

$ g $ git add -A
git commit -m我的本地修改
git pull

解决所有冲突。 然后

  git push 

另外,如果您本地没有宝贵的修改,您可以创建一个新的repo克隆,并从此开始工作:

  git clone https://johnsproject@bitbucket.org/johnsproject/proj.git new_repo_dir 


I am quite new to git, and I had been working on a small side project for the last 2 months and had been pushing stuff onto bitbucket with no problems. A couple of days ago, I zipped my project folder (since I had to reinstall my Linux OS) and now unzipped this after my reinstallation of Linux OS.

So, now, I went to my project folder, kept happily working and finally did:

git add -A && git commit -m "modified code" && git push origin master

..which is what I usually do..

and I get:

To https://johnsproject@bitbucket.org/johnsproject/proj.git
! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://johnsproject@bitbucket.org/johnsproject/proj.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

I have had a look at a few SO questions where they suggest the use of a force flag -f - but I am unsure if I should be doing this.

p.s: I am on the master branch - which is the only branch on my repo.

Would really appreciate if anyone could point me in the right direction here.

Thanks.

解决方案

There are changes in the central repository that you must pull before you can push. Do

git add -A
git commit -m "my local changes" 
git pull

Resolve any conflicts. Then do

git push

Alternatively, if you have no valuable modifications locally, you can create a new clone of your repo, and start working from there:

git clone https://johnsproject@bitbucket.org/johnsproject/proj.git new_repo_dir

这篇关于git拒绝推送非快进的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆