How to recover git after a fatal file system error?

What is the fastest way to restore a git repository after a file system error on the core server?

Imagine that the central server of your OSS project is failing and all transactions are lost within two days after recovery. How to get them back? Is it enough to just call "git push" for all clients? Or is there something else I should take into account?

+3
source share
3 answers

Each repository is also a backup of the "main repository" (which is the "main" only by agreement), therefore git pushfrom the repository in which the latest ones were executed git fetchor there git pullshould be everything that is required - to its state, of course. You only need to take care of the hooks, etc., but if you say that only the last two days of the commission were lost, they probably did not suffer.

+8
source

A git pulland then a git pushshould be enough.

Alternatively, a git push -fwill force the server to update with your local copy, but this can cause problems for others (if there are several commiters).

, .

+2

I think it is better to create a new repo on the server:

% ssh user@server
% mv /path/to/repo /path/to/repo.old
% mkdir /path/to/repo
% cd /path/to/repo
% git init --bare

Then click on all the different clones that you have. My thinking is that this will avoid any corrupted files that might be in the old repo, and there should be no loss if you all work on your own clones and no one interferes with the server repo.

+1
source

Source: https://habr.com/ru/post/1703271/


All Articles