The following assumes that you have a git project hosted in one repository service (e.g, GitHub) that you wish to mirror to another repository service (e.g., BitBucket, AWS CodeCommit, etc). The basic workflow looks like the following:
Procedure Outline:
- Login to a git-enabled host
- Create a copy of your "source-of-truth" repository, depositing its contents to a staging-directory:
git clone --mirror \ <REPOSITORY_USER>@<REPOSITORY1.DNS.NAME>:<PROJECT_USER_OR_GROUP>/<PROJECT_NAME>.git \ stage
- Navigate into the staging-directory:
cd stage
- Set the push-destination to the copy-repository:
git remote set-url --push origin \ <REPOSITORY_USER>@<REPOSITORY2.DNS.NAME>:<PROJECT_USER_OR_GROUP>/<PROJECT_NAME>.git
- Ensure the staging-directory's data is still up to date:
git fetch -p origin
- Push the copied source-repository's data to the copy-repository:
git push --mirror
Procedure Outline:
Using an example configuration (the AMIgen6 project):
$ git clone --mirror git@github.com:ferricoxide/AMIgen6.git stage && \ cd stage && \ git remote set-url --push origin git@bitbucket.org:ferricoxide/amigen6-copy.git && \ git fetch -p origin && \ git push --mirror Cloning into bare repository 'stage'... remote: Counting objects: 789, done. remote: Total 789 (delta 0), reused 0 (delta 0), pack-reused 789 Receiving objects: 100% (789/789), 83.72 MiB | 979.00 KiB/s, done. Resolving deltas: 100% (409/409), done. Checking connectivity... done. Counting objects: 789, done. Delta compression using up to 8 threads. Compressing objects: 100% (369/369), done. Writing objects: 100% (789/789), 83.72 MiB | 693.00 KiB/s, done. Total 789 (delta 409), reused 789 (delta 409) To git@bitbucket.org:ferricoxide/amigen6-copy.git * [new branch] ExtraRPMs -> ExtraRPMs * [new branch] SELuser-fix -> SELuser-fix * [new branch] master -> master * [new branch] refs/pull/38/head -> refs/pull/38/head * [new branch] refs/pull/39/head -> refs/pull/39/head * [new branch] refs/pull/40/head -> refs/pull/40/head * [new branch] refs/pull/41/head -> refs/pull/41/head * [new branch] refs/pull/42/head -> refs/pull/42/head * [new branch] refs/pull/43/head -> refs/pull/43/head * [new branch] refs/pull/44/head -> refs/pull/44/head * [new branch] refs/pull/52/head -> refs/pull/52/head * [new branch] refs/pull/53/head -> refs/pull/53/head * [new branch] refs/pull/54/head -> refs/pull/54/head * [new branch] refs/pull/55/head -> refs/pull/55/head * [new branch] refs/pull/56/head -> refs/pull/56/head * [new branch] refs/pull/57/head -> refs/pull/57/head * [new branch] refs/pull/62/head -> refs/pull/62/head * [new branch] refs/pull/64/head -> refs/pull/64/head * [new branch] refs/pull/65/head -> refs/pull/65/head * [new branch] refs/pull/66/head -> refs/pull/66/head * [new branch] refs/pull/68/head -> refs/pull/68/head * [new branch] refs/pull/71/head -> refs/pull/71/head * [new branch] refs/pull/73/head -> refs/pull/73/head * [new branch] refs/pull/76/head -> refs/pull/76/head * [new branch] refs/pull/77/head -> refs/pull/77/head
Updating (and Automating)
To keep your copy-repository's project in sync with your source-repository's project, periodically do:This can be accomplished by logging into a host and executing the steps manually or placing them into a cron job.cd stage && \ git fetch -p origin && \ git push --mirror
No comments:
Post a Comment