Egit 拒绝非快进 [英] Egit rejected non-fast-forward

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

问题描述

我在推送到 github 存储库时收到此消息.你能告诉我一步一步的程序来修复它吗?我只推了一次就成功了.但是,当我更新一个项目并尝试推送我的第二次提交时,它显示主拒绝非快进"并且不允许我推送.请解释程序.

I am getting this message while pushing to github repository. Can you tell me step by step procedure to fix it? I pushed only once and it was successful. But, when I updated a project and tried to push my second commit, it shows "master rejected non-fast-forward" and does not allow me to push. Please explain the procedure.

推荐答案

我遇到了同样的问题,我能够解决它.afk5min 是对的,问题是您从中提取代码的分支在远程存储库上发生了更改.根据标准的 git 实践(http://git-scm.com/book/en/Git-Basics-Working-with-Remotes),您需要(现在)将远程存储库中的这些更改合并到您的本地更改中,然后才能提交.这是有道理的,这会迫使您接受其他人的更改并将它们合并到您的代码中,确保您的代码在其他更改就位的情况下继续运行.

I had this same problem and I was able to fix it. afk5min was right, the problem is the branch that you pulled code from has since changed on the remote repository. Per the standard git practices(http://git-scm.com/book/en/Git-Basics-Working-with-Remotes), you need to (now) merge those changes at the remote repository into your local changes before you can commit. This makes sense, this forces you to take other's changes and merge them into your code, ensuring that your code continues to function with the other changes in place.

无论如何,进入步骤.

  1. 配置fetch"以获取您最初从中提取的分支.

  1. Configure the 'fetch' to fetch the branch you originally pulled from.

获取远程分支.

将该远程分支合并到您的本地分支.

Merge that remote branch onto your local branch.

在您的本地存储库中提交(合并)更改.

Commit the (merge) change in your local repo.

将更改推送到远程存储库.

Push the change to the remote repo.

详细...

  1. 在 Eclipse 中,打开Git 存储库"视图.

  1. In eclipse, open the view 'Git Repositories'.

确保您可以看到本地存储库,并且可以将远程存储库视为子文件夹.在我的版本中,它称为 Remotes,然后我可以在其中看到远程项目.

Ensure you see your local repository and can see the remote repository as a subfolder. In my version, it's called Remotes, and then I can see the remote project within that.

寻找指向左侧的绿色箭头,这是获取"箭头.右键单击并选择配置提取".

Look for the green arrow pointing to the left, this is the 'fetch' arrow. Right click and select 'Configure Fetch'.

您应该会看到 URI,确保它指向远程存储库.

You should see the URI, ensure that it points to the remote repository.

查看弹出窗口的引用映射部分.我的是空的.这将指示您要获取哪些远程引用.点击添加".

Look in the ref mappings section of the pop-up. Mine was empty. This will indicate which remote references you want to fetch. Click 'Add'.

输入您需要从远程存储库获取的分支名称.我的是大师"(顺便说一句,这里的下拉菜单会很棒!!,现在,你必须输入它).继续浏览弹出窗口,最终点击完成".

Type in the branch name you need to fetch from the remote repository. Mine was 'master' (btw, a dropdown here would be great!!, for now, you have to type it). Continue through the pop-up, eventually clicking 'Finish'.

点击保存并获取".这将获取远程引用.

Click 'Save and Fetch'. This will fetch that remote reference.

查看本地存储库的Branches"文件夹.您现在应该在远程文件夹中看到该远程分支.再次,我看到了主人".

Look in the 'Branches' folder of your local repository. You should now see that remote branch in the remote folder. Again, I see 'master'.

右键单击Branches"的Local"文件夹中名为master"的本地分支.选择合并",然后选择名为origin/master"的远程分支.

Right-Click on the local branch in the 'Local' folder of 'Branches', which is named 'master'. Select 'Merge', and then select the remote branch, which is named 'origin/master'.

处理合并.

提交对本地存储库的任何更改.

Commit any changes to your local repository.

将更改推送到远程存储库.

Push your changes to the remote repository.

去喝一杯美味的饮料,恭喜你自己.休息一天.

Go have a tasty beverage, congratulating yourself. Take the rest of the day off.

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

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