情节: 我有一个本地的develop
和master
分支。develop
比master
超前约90个提交,从大约6个月前开始。
我运行了一个git filter-branch -f --index-filter 'git rm --force --cached --ignore-unmatch media/*' -- --all
命令,重写了比我预期更多的git历史记录,在两个分支上都进行了操作。由于该命令的作用,造成了极多的git操作,这使得我的git reflog
无用了。
我通过简单的git reset --hard origin/master
命令轻松地恢复了master
分支,但是我的develop
分支处于非常糟糕的状态。
现在,显然,master
和develop
之间的提交哈希值不匹配,这使得git认为我有无数个提交需要推送和拉取到/自己的remote/develop
(应该没有需要拉取的提交,需要推送约90个提交)。
是否有一种方法可以使git "协调"所有来自master
和develop
的提交?应该是像这样的:
for commit in commits_in_master:
tmp = search_by_commit_autor_and_date_and_message_in_develop(commit)
tmp.hash = commit.hash
tmp.save()
编辑:
如果我所要求的操作不可行,那么我能否(以某种方式)仅提取未推送到origin/develop
的大约90个提交,然后重置我的develop
分支为origin/develop
,最后应用这些大约90个提交?
fetch
命令后,我只得到了zsh: no matches found: +refs/original/*:*
的提示。 - alexandernst