githerokugithubshallow-clone

Pushing to github after a shallow clone


I had a massive git repo because of a huge number of commits, so following advice here I created a shallow clone. I've made changes to this new local repo, and now I want to push to my origin at Github (and then on to my staging and production remotes on Heroku). Perhaps one day I'll learn to read the documentation:

The git clone --depth command option says

--depth Create a shallow clone with a history truncated to the specified number of revisions. A shallow repository has a number of limitations (you cannot clone or fetch from it, nor push from nor into it)

So... how can I unpick myself from this situation and push my code to Github?


Solution

  • From @nschum

    For future reference: git now supports pushing from shallow clones (since version 1.9). It will still fail when pushing to an outdated fork that's older than your history.

    (Aside: Unfortunately copy/paste is the recommended way to promote a comment to an answer)