Git: Command to fix corrupted repository

I occasionally get fatal, such as:


error: cannot lock ref 'refs/remotes/origin/AB-123': is at dffbe642f088781a5e485227927e141ddb73443a but expected e377921a6d00f4d4c0463774990e03343683177e

Rebasing doesn’t work, but if you do the following it will resolve it:


git gc --prune=now

This guarantees to remove all git garbage.

NOTE: Make sure all your code has been committed before doing this.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.