[英]git merge without merge conflicts from unrelated branch
我有一个在本地机器上损坏的 git 存储库。 为了解决我的问题,我删除了本地机器上的 git 文件并运行git init
。 然后我运行git commit -m "fixing git"
。 我的fix_git分支有我的最新代码,我想拉入我的遥控器并将其与我的develop
分支合并。 我继续并重置了我的远程来源。 然后我尝试拉我的开发分支并收到以下错误
致命的:拒绝合并不相关的历史
然后我尝试了以下git pull origin cleanup --allow-unrelated-histories
它创建了许多合并冲突,以便能够通过。 此外,我打算保留我在本地机器上所做的每一个更改。 我将如何修复它以便我的遥控器进行更改并保留我的历史记录?
定义:
(location alpha) is my local repo file path with my .git file that got corrupted
(location beta) is a new file path
并不是说这是最好的解决方案。 我花了4个小时才得出这个结论。
git clone
到与我的本地存储库(位置 alpha)分开的另一个位置(位置 beta)。git add .
和git commit -m "solving git problems"
git pull -f
我会这样做:
git init .
git add .
git commit "what I want as latest"
git remote add some-remote url-to-repo-with-the-project
git fetch some-remote
git reset --soft some-remote/some-branch
# all changes are in index
git commit -m "Latest changes"
就是这样。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.