Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git local mirror

Tags:

git

mirroring

I have a remote git repository with big history and slow connection channel. Where are some local users, and slow push/pull after big commits or cloning from scratch for new users are big problems, now. I want to create local mirror of it. Local changes must be committed to local repo, and sync with remote in background. I understand that this problem is in demand, but I have not found any solution yet (I am not admin of remote repo, I just try to simplify local work with it).

like image 311
exbluesbreaker Avatar asked Jul 16 '12 10:07

exbluesbreaker


People also ask

What is the difference between Git clone and Git clone mirror?

The difference is that when using --mirror , all refs are copied as-is. This means everything: remote-tracking branches, notes, refs/originals/* (backups from filter-branch). The cloned repo has it all. It's also set up so that a remote update will re-fetch everything from the origin (overwriting the copied refs).

What does mirroring a repository mean?

Repository Mirroring is a way to mirror repositories from external sources. It can be used to mirror all branches, tags, and commits that you have in your repository. Your mirror at GitLab will be updated automatically. You can also manually trigger an update at most once every 5 minutes.


2 Answers

Since you write in the comments that the people behind the slow connection would be doing most of the work, I would suggest you setup the slow remote site to be a mirror of your local repo you would commit against.

First make a bare clone of slow remote on a local server

$ git clone --bare git://slow/repo.git

You local people should now only commit to that clone, not the slow remote.

Then set up a cron job or something similar to push changes in your local repo to the slow site with

$ git push origin --mirror

By using --mirror you tell git to push all branches and tags.

like image 93
Benjamin Bannier Avatar answered Oct 05 '22 09:10

Benjamin Bannier


You should be able to make shallow clones with

git clone --depth=20 url-to-your-repo some-path

This should allow you to not bother with most of the history.

like image 34
Adam Dymitruk Avatar answered Oct 05 '22 09:10

Adam Dymitruk