You can't push a shallow clone into a new remote. You have to unshallow
your clone first. Do a fetch from the old remote with the --unshallow
parameter:
git fetch --unshallow old
and you should be able to push to your new remote. Note that you will need to add back your old remote first to fetch from it.
BUT...
That isn't what you want though. To remove the history from a full clone you would need to use git rebase
to effectively remove the old history. There are other methods but since you only want the last 50 commits, this will be the easiest solution. Assuming the master
branch:
git rebase --onto master~y master~x master
where x
is the number of the first commit to be kept, and y
is the number of the first commit you want to remove. At this point you can push to your new remote with only the history you want to keep. Note you will need to enumerate the commit numbers in git log
yourself, as it wants an index (starting at 1) and not a commit hash.
Take care, as rewriting history can be a dangerous thing in Git, and has other implications you will need to consider. Also make sure not to push the changes to the old remote unless you want to remove the old history there as well.
Source: https://www.clock.co.uk/insight/deleting-a-git-commit