Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which signals can safely be used to kill a Git process and which not?

Tags:

git

process

  • 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

like image 822
mstrap Avatar asked May 07 '12 18:05

mstrap


People also ask

How do you stop a process in git bash?

Solution: press 'q'.


1 Answers

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.

like image 79
sleske Avatar answered Oct 20 '22 01:10

sleske