【问题标题】:Can't Push or Pull in Git无法推送或拉入 Git
【发布时间】:2015-11-18 00:39:52
【问题描述】:

我对使用 Git 还很陌生,但我确实了解基本的基础知识。但是,我还没有遇到过推/拉冲突的情况……直到现在。

另外,我应该指出,我用来与 Git 存储库交互的 GUI 工具是 Atlassian SourceTree(我们使用 Atlassian Stash 来管理我们的存储库)。

这是场景:

我有 2 次提交到 Push,显然我需要对 Pull 进行 4 处更改。

当我尝试Pull 时,我得到了这个:

git -c diff.mnemonicprefix=false -c core.quotepath=false fetch origin

git -c diff.mnemonicprefix=false -c core.quotepath=false pull --no-commit origin master
You have not concluded your merge (MERGE_HEAD exists).

Please, commit your changes before you can merge.

Completed with errors, see above.

它说我需要完成我的合并,但它不允许我做任何事情。我没有得到合并列表,也没有自动合并。我似乎无法通过合并,因此我可以继续解决 Push/Pull 冲突。

当我尝试Push 时,我得到了这个:

git -c diff.mnemonicprefix=false -c core.quotepath=false push -v --tags origin master:master
Pushing to http://XXXXXX@XXXXXXXX.XXXX.XXXX:XXXX/XXXX/XXXX/XXXXX.git
To http://XXXXXX@XXXXXXXX.XXXX.XXXX:XXXX/XXXX/XXXX/XXXXX.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'http://XXXXXX@XXXXXXXX.XXXX.XXXX:XXXX/XXXX/XXXX/XXXXX.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

现在我该怎么解决这个问题?!我将不得不Rebase 或类似的东西吗?

我正在阅读有关 Fast Forward Push 的信息,但我不知道如何在此工具中执行此操作。如果必须,我当然可以从终端执行 Git 命令。我只是不想在没有咨询对 Git 和这些类型的问题有更好理解的人的情况下跳进去。

【问题讨论】:

  • 我刚刚意识到我可能听起来很愚蠢,问我的问题并发布Pull 输出说“You have not concluded your merge (MERGE_HEAD exists). Please, commit your changes before you can merge.”,而没有提到它不允许我合并任何东西的事实。这可能导致对我的帖子投反对票。我已编辑我的帖子以提及该问题。

标签: git atlassian-sourcetree bitbucket-server


【解决方案1】:

看起来您正在合并(可能是之前的尝试?)

git merge --abort 将取消该合并,并使您处于可以重试拉取然后解决冲突的状态。

【讨论】:

  • 感谢您的回复。按照您的建议,我能够使事情正常进行。我尝试了几次,但我仍然看到同样的问题。所以我在再次运行git merge --abort 之前尝试关闭SourceTree,然后我再次运行Pull。然后我打开 SourceTree,我的合并列表终于出现了。我能够继续合并并解决所有其他问题。
  • 感谢您的帮助!我真的很感激。
【解决方案2】:

完成合并。 git status 会告诉你正在玩什么。对于每一个,您都需要编辑以修复冲突并执行git add。然后git commit。然后拉,然后推。

【讨论】:

  • 也感谢您的回复。如果我尝试合并时没有发生奇怪的事情,那么您的回答可能是处理该问题的可接受解决方案。但是,我选择了@Darren Clark 的答案,因为它更适合我的特定场景。再次感谢!
猜你喜欢
  • 1970-01-01
  • 2014-10-01
  • 2015-09-05
  • 1970-01-01
  • 2014-12-11
  • 2020-11-19
  • 2015-02-12
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多