0

We created a bare git repository on our own server, and we want to back it up on a remote server like bitbucket.

What's the best way to do this?

Our solution is to use an update hook after each push, but we're not sure whether this solution covers all kind of changes to the repository.

----- Edit:

Sorry, maybe I didn't describe it clearly. My problem is how to automatically backup a bare git (created by "git init --bare") repository to a remote git repository(when something changed). Not one time back up. And we expect the backup looks like a real time mirror of our own bare git repository.

Yuanqiu Li
  • 143
  • 2
  • 9
  • Possible duplicate of [How do I push a local repo to Bitbucket using SourceTree without creating a repo on bitbucket first?](http://stackoverflow.com/questions/24294034/how-do-i-push-a-local-repo-to-bitbucket-using-sourcetree-without-creating-a-repo) – aug Jun 20 '16 at 06:40
  • @aug Sorry, maybe I didn't describe it clearly. My problem is how to automatically backup a bare git (created by "git init --bare") repository to a remote git repository(when something changed). Not one time back up. And we expect the backup looks like a real time mirror of our own bare git repository. – Yuanqiu Li Jun 20 '16 at 07:01
  • 1
    I think hook + crontab could cover all kinds of changes. – ElpieKay Jun 20 '16 at 07:06

1 Answers1

0

Finally, I found the solution:

git remote add --mirror=push <name> <address>

Triggered in post-receive hook.

Yuanqiu Li
  • 143
  • 2
  • 9