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

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

问题描述

有没有好的方法来解释如何在 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;博士

  1. 如果要解决,请先获取(然后合并).
  2. 如果您想破解,请使用 --force 选项.

不过,您要求的是前者.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天全站免登陆