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

问题描述 投票:16回答:2

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

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

我运行了上述问题的提示和答案,但没有决定。我正在使用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)

我也面临同样的问题。按照运行2个comentos的步骤但没有工作。我认为我的问题是,在我为一个单独的头部结账之前,在个人头部做了一个提交,然后我回到了树枝/主人,并且承诺我做了,我相信引用树头个人。总之,我无法撤消此提交,我在SourceTree软件上以图形方式显示

编辑 - 添加信息:我想抛弃未发布的提交并进行服务器检出。但解决方案我发现互联网不起作用。我也在gitBash中尝试了git reverse,控制台显示了我开发的消息

$ 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)

我尝试了两种解决方案但没有效果。如果我尝试推送给冲突带来了大量的文件,我尝试用自动合并来解决这些问题,但是为了创建一个新的git状态,他指出相同的quantdde文件是冲突的。

git git-commit git-reset
2个回答
43
投票

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

所以当然,重置为origin/master将无法正常工作。您必须重置到该远程分支才能将本地分支重置为该分支。

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

git fetch origin
git reset --hard origin/processos_criminais_151029

-1
投票

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

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

git pull

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

git push

一切都很完美

问候

© www.soinside.com 2019 - 2024. All rights reserved.