Our goal is to do internal development based on a project hosted on an external repo (github) using git and gerrit. We would pull from the external repo periodically to brin
When you perform a git push, it only pushes the active branch (HEAD). If you wish to push all branches and tags, do something like git push origin refs/heads/* --tags
It isn't technically required to have a local copy of the repository before pushing to Gerrit, but it is probably the easiest method.
I believe I've found the answer for myself. It boils down to how you create the repository (and is my formal introduction to bare repos).
In short, you can clone a repo the default way:
git clone https://github.com/foobar/myrepo.git
Which yields a local clone with working directory myrepo, within which is the myrepo/.git directory tree.
Or you can clone it bare. There are a couple of ways to do this, but the --mirror option appears to yields the most complete replica:
git clone --mirror https://github.com/foobar/myrepo.git
This produces the myrepo.git directory (as one might see in gerrit or in gitolite) which has the same structure as the myrepo/.git directory above, but without the working directory bits.
Note: I'll add that I'm not sure now whether a mirror is preferable to a bare clone with remote refs for the branches... I've got another thread going that inquires about this. For completeness, then, here's a way to create a bare clone with remote refs (the key being no working directory):
git init --bare ${LOCAL_REPO}
cd ${LOCAL_REPO}
git remote add origin ${REMOTE_URL}
git fetch origin --tags
git fetch origin
I tested the mirror idea as a one-off, cloning a repo straight into the local gerrit installation folder where All-Projects.git also lives, restarted gerrit and it sees the repo as well as all its branches. However, it's not the ideal way for gerrit. You should instead push from a local clone (preferably a bare one).
So in gerrit, create a new empty project via the web admin interface (I didn't put an initial empty commit into it - not sure if that would cause problems), then from within a local mirror of the repo you're trying to replicate, push it to the new, empty gerrit repo along with the branches and tags:
git push <gerrit_repo> refs/heads/* refs/tags/*