tags:

views:

67

answers:

2

Hi,

I have followed the following instructions in setting a git repository locally in one of my hard drive (1):

https://trac.webkit.org/wiki/UsingGitWithWebKit

I would like to know if it is possible for me to set up another repository in a different hard drive which mirrors the one I setup in (1)? By mirrors, I mean if I commit some changes the other repository can retrieve it.

Thank you.

+2  A: 

Clone a repository from the current one. This will automatically add a remote named origin in the mirror repository. From the cloned repository, you will be able to git pull origin branch_name changes that you made in the current one.

Alan Haggai Alavi
A: 

First, create a 'bare' clone of your existing repository to use as your backup:

$ git clone --bare /path/to/your/repo /path/to/your/backup_repo

Next, navigate to your existing repository add a new remote repository definition:

$ git remote add backup /path/to/your/backup_repo

The name of the remote definition in this instance is called 'backup' but you can call it whatever you like.

Now, whenever you're working on your existing repository you can push the changes to your new backup repository by simply executing the following command:

$ git push backup

You should see results something like this:

Counting objects: 5, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 287 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
To /path/to/your/backup_repo
   7c6f003..9eea051  master -> master

If you want to automate this process so you don't have to manually execute the push, you could probably just wire up a post-commit hook to do it for you.

Shane Bell