本文主要解决以下两个需求
$ git remote add mirror_rep_1 http://192.168.1.24/test/mirror_rep_1.git
$ git remote add mirror_rep_2 http://192.168.1.24/test/mirror_rep_2.git
share_doc.txt
两个远程仓库
Jon@Scorpione MINGW64 /f/Job/Job_ZhongKe/mirror_local (master)
$ touch share_doc.txt
Jon@Scorpione MINGW64 /f/Job/Job_ZhongKe/mirror_local (master)
$ ls -l
total 0
-rw-r--r-- 1 Jon 197121 0 Nov 24 14:52 share_doc.txt
Jon@Scorpione MINGW64 /f/Job/Job_ZhongKe/mirror_local (master)
$ git add .
Jon@Scorpione MINGW64 /f/Job/Job_ZhongKe/mirror_local (master)
$ git commit -m 'mirror push to 2 remote reps'
[master (root-commit) f3f68ed] mirror push to 2 remote reps
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 share_doc.txt
Jon@Scorpione MINGW64 /f/Job/Job_ZhongKe/mirror_local (master)
$ git push mirror_rep_1 master
info: detecting host provider for 'http://192.168.1.24/'...
info: detecting host provider for 'http://192.168.1.24/'...
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 232 bytes | 232.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To http://192.168.1.24/test/mirror_rep_1.git
* [new branch] master -> master
Jon@Scorpione MINGW64 /f/Job/Job_ZhongKe/mirror_local (master)
$ git push mirror_rep_2 master
info: detecting host provider for 'http://192.168.1.24/'...
info: detecting host provider for 'http://192.168.1.24/'...
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 232 bytes | 232.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To http://192.168.1.24/test/mirror_rep_2.git
* [new branch] master -> master
Jon@Scorpione MINGW64 /f/Job/Job_ZhongKe/mirror_local_2 (master)
$ git remote add origin http://192.168.1.24/test/mirror_rep_1.git
Jon@Scorpione MINGW64 /f/Job/Job_ZhongKe/mirror_local_2 (master)
$ git remote set-url --add origin http://192.168.1.24/test/mirror_rep_2.git
share_doc_2.txt
两个远程仓库Jon@Scorpione MINGW64 /f/Job/Job_ZhongKe/mirror_local_2 (master)
$ git remote add origin http://192.168.1.24/test/mirror_rep_1.git
Jon@Scorpione MINGW64 /f/Job/Job_ZhongKe/mirror_local_2 (master)
$ git remote set-url --add origin http://192.168.1.24/test/mirror_rep_2.git
Jon@Scorpione MINGW64 /f/Job/Job_ZhongKe/mirror_local_2 (master)
$ git pull origin master
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), 212 bytes | 35.00 KiB/s, done.
From http://192.168.1.24/test/mirror_rep_1
* branch master -> FETCH_HEAD
* [new branch] master -> origin/master
Jon@Scorpione MINGW64 /f/Job/Job_ZhongKe/mirror_local_2 (master)
$ code .
Jon@Scorpione MINGW64 /f/Job/Job_ZhongKe/mirror_local_2 (master)
$ touch share_doc_2.txt
Jon@Scorpione MINGW64 /f/Job/Job_ZhongKe/mirror_local_2 (master)
$ ls -l
total 0
-rw-r--r-- 1 Jon 197121 0 Nov 24 15:32 share_doc.txt
-rw-r--r-- 1 Jon 197121 0 Nov 24 15:33 share_doc_2.txt
Jon@Scorpione MINGW64 /f/Job/Job_ZhongKe/mirror_local_2 (master)
$ git add .
Jon@Scorpione MINGW64 /f/Job/Job_ZhongKe/mirror_local_2 (master)
$ git commit -m 'upload share_doc_2.txt to two reps'
[master 171a6f5] upload share_doc_2.txt to two reps
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 share_doc_2.txt
Jon@Scorpione MINGW64 /f/Job/Job_ZhongKe/mirror_local_2 (master)
$ git push origin --all
info: detecting host provider for 'http://192.168.1.24/'...
info: detecting host provider for 'http://192.168.1.24/'...
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 12 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 269 bytes | 269.00 KiB/s, done.
Total 2 (delta 0), reused 0 (delta 0), pack-reused 0
To http://192.168.1.24/test/mirror_rep_1.git
f3f68ed..171a6f5 master -> master
info: detecting host provider for 'http://192.168.1.24/'...
info: detecting host provider for 'http://192.168.1.24/'...
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 12 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 269 bytes | 269.00 KiB/s, done.
Total 2 (delta 0), reused 0 (delta 0), pack-reused 0
To http://192.168.1.24/test/mirror_rep_2.git
f3f68ed..171a6f5 master -> master
Jon@Scorpione MINGW64 /f/Job/Job_ZhongKe/mirror_local (master)
$ git branch rep2
$ git checkout rep2
Switched to branch 'rep2'
Jon@Scorpione MINGW64 /f/Job/Job_ZhongKe/mirror_local (rep2)
$ touch private_rep_2.txt
Jon@Scorpione MINGW64 /f/Job/Job_ZhongKe/mirror_local (rep2)
$ git add .
Jon@Scorpione MINGW64 /f/Job/Job_ZhongKe/mirror_local (rep2)
$ git commit -m 'upload new file private_rep_2.txt to remote rep2'
[rep2 bd35ca3] upload new file private_rep_2.txt to remote rep2
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 private_rep_2.txt
Jon@Scorpione MINGW64 /f/Job/Job_ZhongKe/mirror_local (rep2)
$ git push mirror_rep_2 rep2
info: detecting host provider for 'http://192.168.1.24/'...
info: detecting host provider for 'http://192.168.1.24/'...
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 12 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 273 bytes | 273.00 KiB/s, done.
Total 2 (delta 1), reused 0 (delta 0), pack-reused 0
To http://192.168.1.24/test/mirror_rep_2.git
0640b32..bd35ca3 rep2 -> rep2
Jon@Scorpione MINGW64 /f/Job/Job_ZhongKe/mirror_local (master)
$ git checkout rep2
Switched to branch 'rep2'
Jon@Scorpione MINGW64 /f/Job/Job_ZhongKe/mirror_local (rep2)
$ touch private_rep_2.txt
Jon@Scorpione MINGW64 /f/Job/Job_ZhongKe/mirror_local (rep2)
$ git add .
Jon@Scorpione MINGW64 /f/Job/Job_ZhongKe/mirror_local (rep2)
$ git commit -m 'upload new file private_rep_2.txt to remote rep2'
[rep2 bd35ca3] upload new file private_rep_2.txt to remote rep2
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 private_rep_2.txt
Jon@Scorpione MINGW64 /f/Job/Job_ZhongKe/mirror_local (master)
$ git add .
Jon@Scorpione MINGW64 /f/Job/Job_ZhongKe/mirror_local (master)
$ git commit -m 'upload new file private_rep_1.txt to remote rep1'
[master 6b52106] upload new file private_rep_1.txt to remote rep1
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 private_rep_1.txt
Jon@Scorpione MINGW64 /f/Job/Job_ZhongKe/mirror_local (master)
$ git push mirror_rep_1 master
info: detecting host provider for 'http://192.168.1.24/'...
info: detecting host provider for 'http://192.168.1.24/'...
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 12 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 294 bytes | 294.00 KiB/s, done.
Total 2 (delta 0), reused 0 (delta 0), pack-reused 0
To http://192.168.1.24/test/mirror_rep_1.git
171a6f5..6b52106 master -> master