Checking git repo integrity

Posted: 2014-04-08 16:31:03 by Alasdair Keyes

Direct Link | RSS feed

I was merging in code changes to my Dev VM this afternoon and I hit a rather nasty issue; I ran out of space on the virtual disk....

It wasn't difficult to sort the space issue, I created another disk in vmware and added it into the VM and used LVM/resizefs to increase the space available to the filesystem at which point I had plenty of space left to play with (I love LVM!).

Git status showed a list of modified files under the "Changes not staged for commit" section and a git diff off these files showed that they all had their content removed.

Not knowing what to do with my repo, I reversed the changed files with

$ git checkout -- file1 file2 ...

And then just merged in the chages again, this appeared to work but I wanted to be sure that nothing else had broken deeper in git.

I discovered the 'git fsck' command which took about 5 minutes to run and didn't show up any errors.

$ git fsck --full --strict 

All looks good. A useful command to remember.

If you found this useful, please feel free to donate via bitcoin to 1NT2ErDzLDBPB8CDLk6j1qUdT6FmxkMmNz

IT Consultancy Services

I'm now available for IT consultancy and software development services - Cloudee LTD.

Happy user of Digital Ocean (Affiliate link)


Validate HTML 5