Super User is a question and answer site for computer enthusiasts and power users. 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 have created a GIT clone on my backup NAS:

git clone --bare //NAS/GIT/TexRepo //backupnas/backup/GIT/TexRepo.git

Now, continuing to work on the regular repository, what is the best way, practice to have, in order to keep my clone updated?

Do I need to run this command daily? I read somewhere I can edit the push command, is that the solution?

share|improve this question
up vote 0 down vote accepted

You can push from the original repository to the cloned repository. To do so you must first configure a "remote" in the original repository:

cd //NAS/GIT/TexRepo
git remote add backup //backupnas/backup/GIT/TexRepo.git

Now you can push from the original to backup:

git push backup

To keep the clone updated you will have to push regularly.

I do not recommend this but it is possible to automate a push after every commit. Here is an example how to do that.

I consider a push after every commit as going against the designed workflow of git, which specifically allows to rewrite your local history (which hasn't been pushed yet). Read this to learn more about this feature of git.

Think of push as one big commit. You work all day doing local commits and the occasional rewriting of local history. Then, at the end of the day you do one big commit, a push.

share|improve this answer
Thanks, is it possible to make that automated? I mean, on any commit, that the change will be also pushed? – Saariko Sep 15 '11 at 12:08
You can't pull into a bare Git repository, you have to push commits into the bare repo. – Stacey Richards Sep 15 '11 at 13:12
@StaceyRichards: I messed up. I meant fetch. I fixed my answer. – lesmana Sep 15 '11 at 14:58

Take a look at and scroll down to the post-receive or post-update section.

I think what you want is to add a hook in your //NAS/GIT/TexRepo repostory that pushes to your //backupnas/backup/GIT/TexRepo.git repo.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .