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

前端 未结 14 2251
孤独总比滥情好
孤独总比滥情好 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 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
    

提交回复
热议问题