简体   繁体   English

GIT:无法推送到原点/主人

[英]GIT: cannot push to origin/master

在此输入图像描述

This is my situation. 这是我的情况。

I had pushed version 2.1.6, but it was buggy, so I reverted my filesystem to the 2.1.5 and I then made some changes which I tagged 2.1.7. 我推了2.1.6版本,但它有错误,所以我将我的文件系统恢复到2.1.5然后我做了一些更改,我标记为2.1.7。

Now I cannot push 2.1.7 to origin/master as it says: 现在我无法将2.1.7推送到origin / master,因为它说:
Updates were rejected because the tip of your current branch is behind its remote counterpart. 更新被拒绝,因为您当前分支的提示落后于其远程对手。 Integrate the remote changes (eghint: 'git pull ...') before pushing again. 在再次推送之前整合远程更改(eghint:'git pull ...')。

I am very lost now. 我现在很迷茫。 What should I do, if I just want to discard 2.1.6, and set the origin/master to 2.1.7? 如果我只想丢弃2.1.6,并将origin / master设置为2.1.7,我该怎么办?

This is your current situation: 这是你目前的情况:

... ---A------------E master, 2.1.7
       \---B---C---D origin/master

Using git pull --rebase would help you reach this: 使用git pull --rebase可以帮助您实现这一目标:

... ---A---B---C---D---E master, 2.1.7, origin/master

Finally, git push your changes: 最后, git push您的更改:

git checkout master
git pull --rebase
git push

Or simply using git push --force would help you achieve this: 或者只是使用git push --force可以帮助您实现这一目标:

... ---A------------E master, 2.1.7
       \---B---C---D origin/master

git checkout master
git push --force

... ---A------------E master, 2.1.7, origin/master

Have you updated your code before pushing ? 你在推送之前更新了代码吗?

use git pull origin master before you push anything. 在推送任何东西之前使用git pull origin master

I assume that you are using origin as a name for your remote. 我假设您使用origin作为遥控器的名称。 Origin is a remote. 原点是遥控器。 You can use git remote --verbose to see all the remote configured under your git folder. 您可以使用git remote --verbose查看git文件夹下配置的所有远程。

You can use git reset --hard -> Resets the index and working tree. 您可以使用git reset --hard - >重置索引和工作树。 Any changes to tracked files in the working tree since are discarded. 之后对工作树中跟踪文件的任何更改都将被丢弃。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM