2011-11-17 147 views
9

我將一個git倉庫分隔爲3.我已經使用Detach (move) subdirectory into separate Git repository來分離文件夾,並將它們成功推送到新的git倉庫。在現有的回購,我已經使用以下命令清除移動的目錄。git push 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 '[email protected]:/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> 但我想確認,因爲這將修改我現有的回購。

回答

8

您對過濾器分支的使用使您的存儲庫與遠程存儲器不同。正如你所觀察到的,遙控器會拒絕你的推動,並提出警告。在這種情況下,您計劃強制更改存儲庫以匹配您的過濾版本,以便您可以繼續使用強制標誌進行推送。您不應該像這樣更改已發佈的存儲庫 - 但是如果您想要,您可以。記住任何擁有克隆的人都需要通知 - 但是如果沒有其他人 - 那麼繼續。

如果您想要非常小心 - 現在製作另一個原始克隆。然後做你的推動。如果結果出錯 - 因爲始終可以使用備份庫中的push --mirror來強制它。

相關問題