Which signals are safe, which are not?
For those signals which are not safe, which damage could be caused when killing a Git process? Might the working tree be left in an undefined state? Might .git/index or even the .git/objects-database get corrupted?
Are files written in some kind of "atomic" operation by Git? (Working tree files, .git/index, configurations files, and so on ...)
Update: more precise question about signals
Solution: press 'q'.
Actually, git tries quite hard to be fully transactional - i.e. it tries to never leave the repository in an inconsistent state, no matter when or how an operation is interrupted - see this question: Can a git repository be corrupted if a command modifying it crashes or is aborted?
So it should not matter how you terminate the git process, if using SIGTERM, SIGKILL or the red power button. The exception, as noted in the answer above, is that the files in the working directory may be a mix of files from different branches, because the files cannot be replaced all at once.
That said, transaction safety is hard to test (as there are many corner cases), so I would not rely 100% on git being safe in this situation. You should normally be ok, but you might hit a bug from time to time and mess up the repository.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With