在更改Git远程URL后,远程拒绝(不允许浅层更新) [英] Remote rejected (shallow update not allowed) after changing Git remote URL
问题描述
我在Git版本控制下有一个项目,我在服务器和本地计算机上工作。我最初有远程起源集作为我的本地计算机,但我现在想要将其更改为BitBucket。
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?
推荐答案
好像你已经使用了 git clone --depth< number>
克隆你的本地版本。这会导致浅层克隆。这样一个克隆的一个限制是你不能将它推送到一个新的存储库中。
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.
这意味着你必须 unshallow 你的库。
This means that you have to unshallow your repository. To do so you will need to add your old remote again.
git remote add old <path-to-old-remote>
之后,我们使用 git fetch
来获取旧遥控器上的剩余历史记录(如此答案中所述)。
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.
注意 > unhallowing 你的克隆你可以明显地删除旧的远程。
Note: After unshallowing your clone you can obviously remove the old remote again.
这篇关于在更改Git远程URL后,远程拒绝(不允许浅层更新)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!