7

Is it possible to do this? I have a few branches and quite a few commits, and I am trying to
git push - --all origin but I am getting shallow update not allowed.

Thanks in advance.

arduima
  • 413
  • 6
  • 13
  • possible duplicate of [Why can't I push from a shallow clone?](http://stackoverflow.com/questions/6900103/why-cant-i-push-from-a-shallow-clone) – eckes Dec 23 '14 at 07:13
  • 2nd possible dup: http://stackoverflow.com/questions/11375070/pushing-to-github-after-a-shallow-clone – eckes Dec 23 '14 at 07:14
  • Seems like solved in recent releases: http://stackoverflow.com/questions/6941889/is-git-clone-depth-1-shallow-clone-more-useful-than-it-makes-out/21217267 – eckes Dec 23 '14 at 07:16
  • 5
    I believe my question is different because I am trying to push to a new remote, and not where I cloned it from. – arduima Dec 23 '14 at 12:07
  • 1
    @eckes none of those links answers the question. – YPCrumble Apr 01 '16 at 14:22

1 Answers1

0

No, that is not possible.

Having a shadow clone means that they oldest commits in your repository are "inverse dangling", i.e. they point to parent commits that you do not have. This makes your data structure invalid since git normally enforces a complete history - it glosses over the problem as you instructed it to make a shallow clone, but still.

You can only push to remotes that already have the commits you are missing.

So, your solution is to unshallow your clone and then push to your new repository. Alternatively, if you want to avoid having all that history in your repos, you can create the new repository from your own upstream (which hopefully is not shallow) without touching your own repository and then push into it.

AnoE
  • 8,048
  • 1
  • 21
  • 36
  • But it's possible to clone from a locally stored "shallow clone". So why there's a limitation in what can be pushed on a remote? – ceztko Apr 24 '18 at 21:31
  • @ceztko, cloning is no problem, that's just like copying whatever you have. It's when you push, and possible meet a situation where there is no common ancestor line for the end result. The duplicate https://stackoverflow.com/questions/6900103/why-cant-i-push-from-a-shallow-clone has some nice ASCII images for the potential problems in one of the answers. – AnoE Apr 24 '18 at 21:56
  • I think that question is mentioning about the issue with pushing/pulling to/from full history repository, which is a limitation that was removed, so it's not an exact duplicate question. Here we are talking about something slightly different, which is recreating on the remote a locally stored shallow clone using push, which indeed seems not possible for the reasons you're mentioning, but it also seems a limitation that could be relaxed. – ceztko Apr 25 '18 at 08:47
  • @ceztko, I agree; I could see "-f" behaviour where you just force it to do what you want to do. I assume the risk was too high for the `git` developers (or just overlooked...). – AnoE Apr 25 '18 at 13:01