! [拒绝]主控->大师(先获取) [英] ! [rejected] master -> master (fetch first)

查看:41
本文介绍了! [拒绝]主控->大师(先获取)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有好的方法来解释如何在Git中解析"! [rejected] master -> master (fetch first)'"?

Is there a good way to explain how to resolve "! [rejected] master -> master (fetch first)'" in Git?

当我使用此命令$ git push origin master时,它会显示一条错误消息.

When I use this command $ git push origin master it display an error message.

! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'git@github.com:zapnaa/abcappp.git'

推荐答案

答案就在那里,git告诉您先获取.

The answer is there, git is telling you to fetch first.

可能其他人已经推动精通,而您的提交却落后了.因此,您必须获取,合并变更集,然后才能再次推送.

Probably somebody else has pushed to master already, and your commit is behind. Therefore you have to fetch, merge the changeset, and then you'll be able to push again.

如果不这样做(或者更糟糕的是,如果使用--force选项强制它),则可以弄乱提交历史记录.

If you don't (or even worse, if you force it by using the --force option), you can mess up the commit history.

我会详细介绍最后一点,因为这里的一个人只是给出了使用--force选项的非常不好的建议.

I get into more detail about the last point, since a guy here just gave the Very Bad Advice of using the --force option.

由于git是DVCS,因此理想情况下,许多其他开发人员正在使用相同的存储库(或其中的一个分支)来与您进行同一个项目.如果用更改集强行覆盖,则存储库将与其他人的存储库不匹配,因为您重写了历史记录".您将使其他人不满意,并且存储库将遭受损失.也许世界上的小猫也会哭.

As git is a DVCS, ideally many other developers are working on the same project as you, using the same repository (or a fork of it). If you overwrite forcefully with your changeset, your repository will mismatch other people's, because "you rewrote history". You will make other people unhappy and the repository will suffer. Probably a kitten in the world will cry, too.

TL; DR

  1. 如果要解决,请先获取(然后合并).
  2. 如果要黑客攻击,请使用--force选项.
  1. If you want to solve, fetch first (and then merge).
  2. If you want to hack, use the --force option.

不过,您要求的是前者.坚持1),即使您总是自己使用git,也要始终这样做,因为这是一种好习惯.

You asked for the former, though. Go for 1) always, even if you will always use git by yourself, because it is a good practice.

这篇关于! [拒绝]主控->大师(先获取)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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