0

I want to use a repo on a remote git service as a backup for a locally created repo. The remote service is namely Bitbucket, but the question can apply to others.

I can't create a bare repo on Bitbucket (or can I?) so I don't know how to work with 'push --mirror'.

Pushing all branches and commits is sort of ok, but we want to push as much more as possible, such as: tags, remote pointers, remote branches - so that if we clone back downstream, we get a clone that is close enough to the original local repo without the need for too much re-wiring.

We are not concerned about uncommitted work or the working directory or staging area. The workflow is to do a commit then follow by a push to the backup.

We are not seeking a perfect clone that covers working and staging areas. Also we are not seeking a bullet proof backup, I understand that branches can be deleted on local and lost on remote. So basically this is about an easy way to do a partial backup to a service that is already there and providing free private accounts - which provides some level of redundancy and thus some piece of mind.

How can I achieve the above.

First Edit:

This is a log of first trial - not what I expected from my all-local tests, but this in what I'm getting:

  • create repo on Bitbucket:
https://shishani@bitbucket.org/shishani/test1.git
  • local session
$ git remote add bbtest1  https://shishani@bitbucket.org/shishani/test1.git

$ git status
# On branch master
nothing to commit (working directory clean)

$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master

$ git remote -v
bbtest1   https://shishani@bitbucket.org/shishani/test1.git (fetch)
bbtest1   https://shishani@bitbucket.org/shishani/test1.git (push)
origin    /more/coding/git-tests/test-orig (fetch)
origin    /more/coding/git-tests/test-orig (push)


$ git push --mirror  bbtest1 
Password: 
fatal: remote part of refspec is not a valid name in :capabilities^{}
fatal: The remote end hung up unexpectedly

Any idea what's going on ?!

Second Edit:

I forked a separate question for the unexpected error message here: fatal: remote part of refspec is not a valid name in :capabilities^{}

Community
  • 1
  • 1
Basel Shishani
  • 7,735
  • 6
  • 50
  • 67

1 Answers1

1

I have not used BitBucket, but the process will be more or less equivalent with any of these hosting providers:

Create the remote repository. (eg: test)

Add it as a remote to git:

# these paths should be accurate, but check your repo provider
git add remote bitbucket https://you@bitbucket.org/you/test.git
git add remote github git@github.com:you/test.git

Push to it:

git push bitbucket --mirror
git push github --mirror
Daniel Pittman
  • 16,733
  • 4
  • 41
  • 34
  • Thanks, please check my edit - I meant to reproduce my all-local tests, but I'm getting something new unexpected with Bitbucket. – Basel Shishani Feb 12 '12 at 02:36
  • I suspect a local ref has a name that the remote isn't accepting, but I can't tell why. There is something odd in the local repository, though, since the steps you followed should have worked. I would suggest pushing each ref in turn, to find out which one is bad. – Daniel Pittman Feb 12 '12 at 02:46