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

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

我提出了一个与我的问题最相符的问题,但无法添加评论。

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

我运行上面问题的提示和答案,但没有决定。我正在关注使用软件源代码树的进度表。我关闭了软件和 运行 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)

我也遇到了同样的问题。按照步骤 运行ning 2 commentos 但没有奏效。我认为我的问题是,在我为一个单独的头进行结帐之前,在个人头中进行了提交,然后我回到了树 b运行ch / master,并提交了我所做的,我相信参考文献树头个体。总之我无法撤消此提交,我在 SourceTree 软件上以图形方式显示

编辑 - 添加信息: 我想扔掉未发布的提交并进行服务器结帐。但是我发现互联网无法正常工作的解决方案。我还在 gitBash 中尝试了反向 git 控制台显示我执行 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)

我尝试了这两种解决方案,但 none 奏效了。如果我尝试推送大量文件导致冲突,并且我尝试通过自动合并解决这些问题,但要创建一个新的 git 状态,他指出相同的 quantidde 文件存在冲突。

Your branch and 'origin / processos_criminais_151029' have diverged

所以当然,重置为 origin/master 是行不通的。您必须重置到该远程分支才能将您的本地分支重置到它。

所以您需要 运行 的命令是:

git fetch origin
git reset --hard origin/processos_criminais_151029

我用这个link解决了这个问题:

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

git pull

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

git push

一切都很完美

此致