Pushing to github after a shallow clone

前端 未结 5 926
春和景丽
春和景丽 2020-12-02 23:56

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 t

5条回答
  •  悲哀的现实
    2020-12-03 00:12

    I will not agree with the accepted answer for 2 reasons:

    1. There are many reasons to fail and forget a file
    2. You lose your commit messages and history

    Here are my suggestions:

    Graft point

    You should have a $GIT_DIR/.git/shallow file with a graft point. If the history is simple enough, this graft point should allow you to push even though documentation says otherwise.

    Patches

    This allows you to keep commit history and etc:

    git format-patch origin..master
    

    Then clone the origin and reapply:

    git clone origin_path
    cp shallow_clone/*.patch deep_clone
    cd deep_clone
    git am *.patch
    

    This time you can push !

    git push
    

提交回复
热议问题