shallow update not allowed


! [remote rejected] master -> master (shallow update not allowed)

https://stackoverflow.com/questions/28983842/remote-rejected-shallow-update-not-allowed-after-changing-git-remote-url

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:

  1. if you don't care about you're current or missing history, take a look at this question
  2. if you want to keep your full history, then continue reading:

So, you want to keep your history, eh? 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>

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 obviously remove the old remote again.

 

個人分析:

比如從網址1(github) clone一個repository,但是repository很大。過了一段時間,可能git后台回收了一部分objects,太久不用的。

那么等你想要更換網址2(osc)的時候,比如push到osc的時候。

這個時候push,可能就會少一些文件。

那么需要git fetch --unshallow github

然后再git push osc

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM