serby serby - 6 months ago 47
Git Question

How do you update a bare repo from a remote source using git

I have a repo that is a bare clone of a github repo:

git clone --bare

A number of developers clone that repo and push back to it.

Another developer has committed directly to the github repo.

I would like to know how to get the changes on github back into the bare repo for the other developers to pull from.

I have tried:

git fetch origin

Which seems to fetch to:


But I can't get local head to have the changes.

The closest question I can find is this:

GIT: How do I update my bare repo?

This suggests mirroring, but I would like to know if there is a way to achieve this without the need to mirror.


clone the bare repo yourself. This will have origin pointing to that. Now add the github repo as 'github' remote. You can now fetch the branches and tags from github and in turn push them to origin.

git fetch github
git push origin github/yourbranchname:yourbranchname

Hope this helps.