git reset –hard origin/master failing

Had the same issue, which quite crazy cause reset --hard should always work, but it seems the working tree had a lot of differences to my target branch.

I had no time to dig this down, but found this by accident:

  1. Run git gc to do some garbage collection. It will remove unnecessary files and optimize the local repository (more info about git gc can be found here).

  2. Simply reset and finally reset --hard to desired branch.

    $ git gc
    
    $ git reset
    
    $ git reset --hard <target_branch>
    

Leave a Comment

error code: 521