2016-02-19 85 views
3

我試圖減少一個大型資料庫的歷史。我做了一個淺克隆如何在沒有不合適的情況下解除克隆?

git clone --depth --no-single-branch 1000 url 

然後我檢查了所有分支機構,該腳本

#!/bin/bash 
for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master `; do 
    git branch --track ${branch#remotes/origin/} $branch 
done 

在那之後,我已經改變了原點

git remote add new-origin new-url 
git remote rm origin 
git remote mv new-origin origin 

然後我做了一個推新的存儲庫。我的問題是系統不允許推送到一個新的存儲庫一個淺層克隆。如果我回到我的老倉庫到unshallow有:

git fetch --unshallow 

那麼整個回購再次同步。你知道一個方法來解開我的克隆而不留下遺漏嗎?

謝謝

+1

你確定你的回購是從新的回購?也許在獲取時明確指定新的存儲庫會有所幫助。 – Kzqai

+0

我的不好,我糾正了我的問題。 – Killrazor

回答

3

所以這裏是你想要做的。繼續並克隆整個回購,或fetch --unshallow。現在,讓我們假設您想要作爲新回購的根提交的提交SHA爲abc123。請執行以下操作:

git checkout --orphan temp abc123 
git commit -C abc123 #creates a root commit with the contents and commit message of abc123 
git replace abc123 temp #"tricks" git into using the root commit instead of `abc123` 
git filter-branch -- --all #rewrites the whole repo 
git checkout master 
git branch -D temp 

然後,您可以推送到您的新遠程回購。

相關問題