I have a project under Git version control that I worked on both a server and my local computer. I originally had the remote origin set as my local computer but I would now like to change that to BitBucket.
On the server I used the command
git remote set-url origin bitbucket_address
But now when I try to push my project I get the error
! [remote rejected] master -> master (shallow update not allowed)
What is causing this and how do I fix it?
As it seems you have used git clone --depth <number>
to clone your local version. This results in a shallow clone. One limitation of such a clone is that you can't push from it into a new repository.
You now have two options:
So, you want to keep your history, eh? This means that you have to unshallow your repository. If you already removed or replaced your old remote then you'll need to add it again:
git remote add old <path-to-old-remote>
After that we use git fetch
to fetch the remaining history from the old remote (as suggested in this answer).
git fetch --unshallow old
And now you should be able to push into your new remote repository.
Note: After unshallowing your clone you can remove the old remote.