How can I recover my Git repository for a “missing tree” error?

前端 未结 14 2148
孤独总比滥情好
孤独总比滥情好 2020-12-08 02:23

We are using Gerrit for our Git repository. On a project that has been active for several months, we are suddenly unable to push any changes. When we execute git pus

相关标签:
14条回答
  • 2020-12-08 02:59

    I deleted my master branch and created once again. Its working . git branch -D master, git checkout master Luckily it working

    0 讨论(0)
  • 2020-12-08 03:00

    Weird, the --no-thin argument didn't work for me. What worked was a git pull (so probably git fetch.

    0 讨论(0)
  • 2020-12-08 03:01

    This generally happens when time of commit and push is different and which ultimately creates a mismatch between both the trees. Given a remote branch upstream and local branch foo

    Firstly throw away all the uncommitted changes using

    git reset --hard foo
    

    Then track the remote branch using

    git branch --set-upstream-to=upstream/foo
    

    And finally

    git pull
    
    0 讨论(0)
  • 2020-12-08 03:01

    In my case it turned out I forgot to git fetch before git rebase -i origin/master. Thus when I tried to push to gerrit, I got the above error.

    0 讨论(0)
  • 2020-12-08 03:03

    I am getting this same error on my tortiuse git. I finally get the root cause of this error.

    The steps which causes this error;

    • Create a new branch on head.
    • Do some modifications on new branchs
    • Somebody also make modifications on head branch
    • Try to push your branch

    This error will occur if a local branch is created and not pushed until some modifications ara made in head branch. This is a normal thing, since remote head branch do not know anything about your local branch until a push action.

    To solve this error, switch the head branch get a full pull action. Then switch your branch and try a push.

    0 讨论(0)
  • 2020-12-08 03:04

    Try a git pull --rebase.

    I saved the diff (git show > ~/mychanges.txt, took out the commit msg at the top of the file). The checked out a new branch (git checkout -b newbranch) applied the changes (git apply ~/mychanges.txt), and then did a git pull --rebase. Then everything worked.

    0 讨论(0)
提交回复
热议问题