4 ms·
It's dangerous to think that nothing can ever happen to your repository, corruptions or weird states you don't know how to recover from are not even rare. So d
by g-b-r 10mo ago
It's dangerous to think that nothing can ever happen to your repository, corruptions or weird states you don't know how to recover from are not even rare.
So do take backups, of the whole local repository.
At the beginning of using git I used to keep dozens of copies around, if the repository is not huge it's trivial (and compressed they typically don't take up much more space than a single copy).
That saved my ass several times
- globular-toast 10mo agoOf course you should keep backups. But that's a different abstraction level. I have never in 15+ years of using git daily encountered one of these "weird states". Because, like I said, no command in git can modify or delete a commit. The only real mistake you can make is hard reset with uncommitted changes in your working dir. Other than that it's down to git bugs, which I have never encountered.
- g-b-r 10mo agohttps://stackoverflow.com/questions/66449211/a-lock-file-already-exists-in-the-repository-which-blocks-this-operation-from-c https://stackoverflow.com/questions/66449211/a-lock-file-alr... happens fairly easily, and at least years ago it was not easy to figure out how to solve it. I think I did run in other bugs that did appear to have messed up the repository. > like I said, no command in git can modify or delete a commit. Well, you can end up losing commits by playing with the reflogs or deleting branches (if you haven't checked out the branch in the last by default 30 days, its commits might get deleted quickly)
- globular-toast 10mo agoI've never run into index.lock nor had anyone else run into it after it being the "git guy" at various employments. Garbage collection is a thing, of course, but it could be completely disabled if necessary. Most people don't bother because the defaults are sensible in virtually all cases. Almost all git problems people have are because they don't know about the reflog and don't understand that git is fundamentally append only.
- g-b-r 10mo ago> I've never run into index.lock nor had anyone else run into it after it being the "git guy" at various employments. Weird, to me it happened several times > Garbage collection is a thing, of course, but it could be completely disabled if necessary Yeah, I do set reflogs to not expire