【发布时间】:2018-11-21 09:17:38
【问题描述】:
我认为 Sourcetree 中的 Amend last commit 仅用于“最后提交的消息”并在提交时使用它。但它引发了以下错误
我尝试从远程提取,但“无法从不相关的历史中提取”。
我的问题是,Amend last commit 不仅仅是一条消息吗?为什么会出现不相关的历史错误?
【问题讨论】:
标签: git github gitlab atlassian-sourcetree
我认为 Sourcetree 中的 Amend last commit 仅用于“最后提交的消息”并在提交时使用它。但它引发了以下错误
我尝试从远程提取,但“无法从不相关的历史中提取”。
我的问题是,Amend last commit 不仅仅是一条消息吗?为什么会出现不相关的历史错误?
【问题讨论】:
标签: git github gitlab atlassian-sourcetree
默认情况下,修改最后一次提交会在 git push 上触发“在其远程对应项之后”错误,如果之前推送了该 mast 提交。
它改变了最后一次提交:
-x--x--x (master, origin/master)
使用 amend 更改最后一次提交:
-x--x--X' (master)
\
x (origin/master)
如果远程存储库只有一个提交,则可能会发生“无法从不相关的历史中提取”:更改本地存储库意味着:没有共同的祖先。
(如果没有,请阅读““refusing to merge unrelated histories” failure while pulling to recovered repository”)
你可以pull allowing for unrelated history to be merged
git pull origin master --allow-unrelated-histories
git merge origin origin/master
...或者你可以简单地,如果你是唯一一个在远程仓库工作的人,强制推送。
git push --force
【讨论】: