I'm trying to reduce the history a la large repository. I made a shallow clone
git clone --depth --no-single-branch 1000 url
Then I checked all branches with this script
#!/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
After that, I've changed the origin
git remote add new-origin new-url
git remote rm origin
git remote mv new-origin origin
And then I made a push on the new repository. My problem is that system does not permit to push to a new repository a shallow clone. If I return to my old repository to unshallow with:
git fetch --unshallow
then the whole repo is synced again. Do you know a way to unshallow my clone without unshallow?
Thanks
So here is what you want to do. Go ahead and clone the whole repo, or fetch --unshallow
. Now, let's say the SHA of the commit you want as the root commit of your new repo is abc123
. Do the following:
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
Then you can push to your new remote repo.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With