我要将一个git仓库分为3个,我已经使用从 Git 仓库中分离(移动)子目录来将文件夹分离并成功地推送到了新的git仓库。在原有的仓库中,我使用了以下命令清除已移动的目录。
git filter-branch -f --index-filter "git rm -q -r -f --cached --ignore-unmatch lib/xxx/$REPO" --prune-empty HEAD
现在当我在原始代码库上执行 git st
命令时,会得到以下输出:
# On branch 1.5.0
nothing to commit (working directory clean)
当我尝试执行git push
时,我得到以下错误:
! [rejected] 1.5.0 -> 1.5.0 (non-fast-forward)
error: failed to push some refs to 'git@github.com:/xxx/.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again. See the
'Note about fast-forwards' section of 'git push --help' for details.
我的猜测是使用-f选项:git push -f origin <branch>
,但我希望确认一下,因为这将修改我的现有仓库。