【问题标题】:git: Your branch and 'origin/somebranch' have diverged - how to throw away local commitsgit:你的分支和'origin/somebranch'已经分歧-如何丢弃本地提交
【发布时间】:2015-12-14 07:49:01
【问题描述】:

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

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)

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

编辑 - 添加信息: 我想放弃未发布的提交并进行服务器结帐。但是我发现互联网无法正常工作的解决方案。我还在 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)

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

【问题讨论】:

标签: git git-commit git-reset


【解决方案1】:

你的分支和'origin / processos_criminais_151029'已经分歧了

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

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

git fetch origin
git reset --hard origin/processos_criminais_151029

【讨论】:

    【解决方案2】:

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

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

    git pull
    

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

    git push
    

    一切都很完美

    问候

    【讨论】:

    • 这会创建一个合并提交
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-28
    • 1970-01-01
    • 2020-11-21
    • 2020-10-19
    • 2017-05-26
    • 2021-07-07
    相关资源
    最近更新 更多