git:你的分支和“origin/somebranch”已经不同了——如何丢弃本地提交

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32630379/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 03:36:22  来源:igfitidea点击:

git: Your branch and 'origin/somebranch' have diverged - how to throw away local commits

gitgit-commitgit-reset

提问by Paulo Victor

I have a question that most closely matches my problem was made, but could not add a comment.

我有一个与我的问题最匹配的问题,但无法添加评论。

git: Your branch and 'origin/master' have diverged - how to throw away local commits?

git:你的分支和'origin/master'有分歧 - 如何丢弃本地提交?

I ran the tips and answers to the question above, but nothing decided. I am following with a progress chart using the sofwae source tree. I close the software and run the commands in the bash git. But there is the same mistake quoted.

我运行了上面问题的提示和答案,但没有任何决定。我正在跟踪使用 sofwae 源树的进度表。我关闭软件并在 bash git 中运行命令。但是引用了同样的错误。

# Your branch and 'origin/master' have diverged,
# and have 7 and 11 different commits each, respectively.
#   (use "git pull" to merge the remote branch into yours)

I am also facing the same problem. follow the steps running 2 comentos but not worked. I think my problem is that before I made a checkout for a indiividual head, made a commit in individual head and then I went back to the tree branch / master, and commit that I did, I believe that references the tree head individual. In summary I can not undo this commit, I'm displayed graphically on SourceTree software

我也面临同样的问题。按照运行 2 个评论但不起作用的步骤进行操作。我认为我的问题是,在我为个人头结帐之前,在个人头中进行了提交,然后我回到树枝/主节点,并提交了我所做的,我相信引用了树头个人。总之,我无法撤消此提交,我在 SourceTree 软件上以图形方式显示

EDIT - ADD INFORMATION:I'd like to throw out of the unpublished commits and make server checkout. But the solutions I found an internet not working. I also tried git reverse in gitBash the console displays the message that I do deveo

编辑 - 添加信息:我想丢弃未发布的提交并进行服务器检出。但是我发现互联网无法正常工作的解决方案。我也在 gitBash 中尝试了 git reverse 控制台显示了我做 deveo 的消息

$ Git status
On branch processos_criminais_151029
Your branch and 'origin / processos_criminais_151029' have diverged,
and 7 and 11 have different commits each, respectivamente.
?? (use "git pull" to merge the remote branch into yours)

Changes not staged for commit:
?? (use "git add <file> ..." to update what will be committed)
?? (use "git checkout - <file> ..." to discard changes in working directory)

I tried the two solutions but none worked. If I try and push gives the conflict a huge amount of files, and I tried to solve these problems with the automatic merge, but to make a new git status he points out that the same quantidde files are conflicts.

我尝试了两种解决方案,但都没有奏效。如果我尝试推送会产生大量文件冲突,并且我尝试通过自动合并来解决这些问题,但是为了创建新的 git status,他指出相同的 quantidde 文件是冲突的。

回答by poke

Your branch and 'origin / processos_criminais_151029' have diverged

您的分支和 'origin / processos_criminais_151029' 有分歧

So of course, resetting to origin/masterwill not work. You will have to reset to that remote branch in order to reset your local branch to it.

所以当然,重置为origin/master不起作用。您必须重置到该远程分支才能将本地分支重置为该分支。

So the commands you need to run are this:

所以你需要运行的命令是这样的:

git fetch origin
git reset --hard origin/processos_criminais_151029

回答by juanitourquiza

I solved this problem with this link:https://stackoverflow.com/a/32630762/2400373

我用这个链接解决了这个问题:https: //stackoverflow.com/a/32630762/2400373

But is important this steps for complete the answer Then I made a:

但是这个步骤对于完成答案很重要然后我做了一个:

git pull

add changes to the files and do a:

添加对文件的更改并执行以下操作:

git push

and everything works perfect

一切都很完美

Regards

问候