Which signals can safely be used to kill a Git process and which not?
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?
- Checkout branch in Git Extensions creates branch with uppercase name
- KDiff3 under cygwin git will not invoke
- how do I export svn repository to git when I don't have svn credential?
- Recover once staged but not committed files?
- Un-stage file with libgit2
- Make a git branch equal to master again
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
2 Solutions collect form web for “Which signals can safely be used to kill a Git process and which not?”
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.
That depends on what GIT is doing when you try to kill it.
If you kill it during a clone, sure it will be left in some partially incomplete state, but it’s easy to recover from that: delete the messy partial clone and clone again.
In my experience, GIT doesn’t slaughter the files it’s managing when it fails. I’ve killed it in the middle of pushes before without much damage to the files I changed. Granted, the message log can get a little screwy.
Without much more detail than what you’ve provided, it’s hard to say.