https://github.com/norgul/git-mirror
Mirroring/cloning a set of git repositories to a remote location
https://github.com/norgul/git-mirror
bitbucket git github mirror mirrored-repositories
Last synced: 2 months ago
JSON representation
Mirroring/cloning a set of git repositories to a remote location
- Host: GitHub
- URL: https://github.com/norgul/git-mirror
- Owner: Norgul
- Created: 2019-05-23T16:41:18.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-07-19T06:57:58.000Z (about 6 years ago)
- Last Synced: 2025-02-28T02:26:41.221Z (8 months ago)
- Topics: bitbucket, git, github, mirror, mirrored-repositories
- Language: Shell
- Homepage:
- Size: 8.79 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Git mirror
This is a short script for mirroring a set of repositories
to a different location together with all branches tags and
commit history.For example:
```
https://github.com/user/repo1.git ==> https://github.com/new_location/clone1.git
https://github.com/user/repo2.git ==> https://github.com/new_location/clone2.git
https://github.com/user/repo3.git ==> https://github.com/new_location/clone3.git
```# Usage
Download the repository `git clone https://github.com/Norgul/git-mirror.git`
and then enter the repository `cd git-mirror`.**Note:** running any of commands will create a new `git-mirror`
folder at your home directory which will hold bare repositories.
Once cloned, they won't be re-downloaded, just updated on each
command run.## Single repository transfer
Simply run `./git-mirror.sh PRIMARY SECONDARY` where `PRIMARY`
is the ful URL to original, main repository. `SECONDARY` is
the clone repository which will be overwritten with data from
`PRIMARY` repo.## Multiple repository transfer
In order to mirror multiple repositories, you need to create
the `repos.txt` (or which ever name you'd like to use) file
with a pair of space separated repositories, each pair in new line.
Repositories should be full URL to the repository.For example:
```
https://...repo1.git https://...clone1.git
https://...repo2.git https://...clone2.git
https://...repo3.git https://...clone3.git
```Once the file is full, simply run `./repo-mirror.sh /location/to/repos.txt`, and rest
will be done automatically.# Continuous mirroring
You can continuously mirror your set of repositories (or just a
single one) by setting up a cron job which will run the script
periodically.For that to work without user prompt you will need to set passwordless
ssh access.First generate SSH key with no password with `ssh-keygen -t rsa -C "mail@somewhere.com"`
and hit enter twice when it asks for password without entering anything.After that go and enter SSH key to both of your repos and copy the `.pub` from key.
Once that is done you need to add a `config` file in `.ssh` folder:
```
# ~/.ssh/config
Host *hostname*
Hostname *hostname*
User git
IdentityFile ~/.ssh/*your passwordless ssh key (id_rsa if you used default)*
```Test the config by doing:
```
git clone git@your.hostname.com:username/reponame.git
```If this is successful, you should be okay.
**Note** If you are using 2 different hosts, you will have to make 2 entries in
SSH config file.