Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

2 Answers 2

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
add comment

Take a look at http://book.git-scm.com/5_git_hooks.html 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
add comment

Your Answer

 
discard

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.