Can I ever lose my perfect job in git?

Is it possible to lose work in git? Suppose all my work is done and I did not run git gc . If I try some funk command (NOT rm -rf .git ) and something strange happens to my project, can I recover from it? Is there anything special I should avoid? Or clone the vault elsewhere before trying it?

+4
source share
1 answer

Most of the mistakes you make with git can be repaired with reflog . The only exception is deleting your branch, because of course it deletes the file associated with it. If this happens, you can still find the branch again by looking at the HEAD header, but if you did not check the branch after a while (or never check the last end of the branch), then it won 'be there. But even then, you can try using git fsck --lost-found to find your dangling commits, and trawl them to find likely candidates for the branch hint.

As you have already indicated, if you run something that corrupts the .git directory, then all bets are disabled.

+6
source

All Articles