2016-02-19 83 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 

然后,您可以推送到您的新远程回购。

相关问题