Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was thinking about hosting my private project on my server (i may use 'gitolite') and have a copy on my local machine as backup (git clone then automated git fetch every few minute). I want to know what happens if there is a bug gitolite or somewhere else on my server and the source code and git repository has been tampered with? Will my backup also be corrupted? will i easily be able to revert the source using the history?

share|improve this question
up vote 2 down vote accepted

Git maintains its integrity quite well. If you know the SHA-1 of the HEAD, and you usually do that if you have a local copy, then you can be totally sure that the whole tree of that commit is unaltered. So when the server's version is corrupted, for what reason ever, you will easily notice that when you try to interact with it again. Either you will pull wrong revisions, in which case you can simply ignore or remove them, or you will push the correct versions again, which automatically restores the remote repository. There is no real way to corrupt your local version as well, as long as you use git's methods to update each repository.

However, I don't really get why you want to backup the repository via fetch. Usually you are working on a local respository, in which case you already have a full backup, so you don't need another repository that just keeps cloning it. Also instead of repeatedly running fetch, you can just use a normal backup routine to backup the whole repository folder. So you don't need to use git methods just to back it up.

share|improve this answer
I'm a bit confused. What i actually meant is i would like to backup my repository and multiple forks. I may have automated pulling (and a revert if there are conflicts) but most likely not. Actually now that i think of it, everyone will have a copy locally and i doubt the server and local copy will be destoried at the sametime. However i am still worried someone can get on the server and tamper with the repos – acidzombie24 Jan 12 '11 at 18:41
How do i update each repo with git methods? What is the normal backup routine. – acidzombie24 Jan 12 '11 at 18:43
To backup, a simple folder copy is fine. If you want to use git for that, using a simple git fetch works too, that updates the remote branches as well. – poke Jan 12 '11 at 21:32

Backup the folder that the project is in (its 'root') which includes the .git directory tree of files that are the contents of git.

Backing up 'outside' of git is a good idea - although be aware that after any add or change it's out of date, as in the nature of daily backups.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.