我正在尝试减少大型存储库的历史记录。我做了一个浅克隆
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
然后我在新存储库上进行了推送。我的问题是系统不允许将浅克隆推送到新存储库。如果我返回到我的旧存储库以取消浅化:
git fetch --unshallow
然后整个仓库再次同步。你知道一种不用 unshallow 来 unshallow 我的克隆的方法吗?
谢谢
最佳答案
这就是你想要做的。继续并克隆整个存储库,或 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
然后您可以推送到新的远程仓库。
关于git - 如何在没有 unshallow 的情况下取消克隆?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35509581/