0
我知道,通过push-to-empty和clone-mirror,你可以将很多东西推送到新的仓库,而不仅仅是你的提交。例如,您可以获得远程分支复制。但是有什么方法可以通过遥控器自己传输?我可以将遥控器推到遥控器吗?
特别是在克隆镜像中,我直观地认为它应该是其他存储库中所有内容的镜像。所以我很惊讶,这似乎不包括遥控器。
在下面的例子中,我用两个遥控器“dest”和“blah”拍摄了一个repo(“repo1”),并将其推送到一个新的裸仓库“repo2”(push-to-empty)。我也采取了相同的“repo1”并将其克隆到“repo3”。在“repo2”的情况下,没有任何遥控器或遥控器被推入。在“repo3”的情况下,复制了“dest”远程的远程参考(注意:公平,当我推入“repo2”时,该分支不存在,因为它跟踪相同),但是没有跟踪其他遥控器(“blah”)。
C:\test-remote>mkdir repo1bare
C:\test-remote>cd repo1bare
C:\test-remote\repo1bare>git init --bare
Initialized empty Git repository in C:/test-remote/repo1bare/
C:\test-remote\repo1bare>git ls-remote .
C:\test-remote\repo1bare>cd ..
C:\test-remote>git clone .\repo1bare .\repo1wd
Cloning into '.\repo1wd'...
warning: You appear to have cloned an empty repository.
done.
C:\test-remote>cd repo1wd
C:\test-remote\repo1wd>git remote -v
origin C:/test-remote/.\repo1bare (fetch)
origin C:/test-remote/.\repo1bare (push)
C:\test-remote\repo1wd>copy con dummy.txt
^Z
1 file(s) copied.
C:\test-remote\repo1wd>git add dummy.txt
C:\test-remote\repo1wd>git commit -m "dummy"
[master (root-commit) bf946c1] dummy
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 dummy.txt
C:\test-remote\repo1wd>git push -u origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 211 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To C:/test-remote/.\repo1bare
* [new branch] master -> master
Branch master set up to track remote branch master from origin.
C:\test-remote\repo1wd>cd ..\repo1bare
C:\test-remote\repo1bare>git ls-remote .
bf946c1f3d14b287b2973fdfcca7379415dbc486 HEAD
bf946c1f3d14b287b2973fdfcca7379415dbc486 refs/heads/master
C:\test-remote\repo1bare>git remote -v
C:\test-remote\repo1bare>git remote add blah http://blah.com/repo1
C:\test-remote\repo1bare>git remote -v
blah http://blah.com/repo1 (fetch)
blah http://blah.com/repo1 (push)
C:\test-remote\repo1bare>cd ..
C:\test-remote>mkdir repo2bare
C:\test-remote\repo1bare>cd repo2bare
C:\test-remote\repo2bare>git init --bare
Initialized empty Git repository in C:/test-remote/repo2bare/
C:\test-remote\repo2bare>cd ..\repo1bare
C:\test-remote\repo1bare>git remote add dest C:\test-remote\repo2bare
C:\test-remote\repo1bare>git remote -v
blah http://blah.com/repo1 (fetch)
blah http://blah.com/repo1 (push)
dest C:\test-remote\repo2bare (fetch)
dest C:\test-remote\repo2bare (push)
C:\test-remote\repo1bare>git push --all dest
Counting objects: 3, done.
Writing objects: 100% (3/3), 211 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To C:\test-remote\repo2bare
* [new branch] master -> master
C:\test-remote\repo1bare>cd ..\repo2bare
C:\test-remote\repo2bare>git remote -v
C:\test-remote\repo2bare>git ls-remote .
bf946c1f3d14b287b2973fdfcca7379415dbc486 HEAD
bf946c1f3d14b287b2973fdfcca7379415dbc486 refs/heads/master
C:\test-remote\repo2bare>cd ..
C:\test-remote>git clone .\repo1bare --mirror .\repo3bare
Cloning into bare repository '.\repo3bare'...
done.
C:\test-remote>cd repo3bare
C:\test-remote\repo3bare>git remote -v
origin C:/test-remote/.\repo1bare (fetch)
origin C:/test-remote/.\repo1bare (push)
C:\test-remote\repo3bare>git ls-remote .
bf946c1f3d14b287b2973fdfcca7379415dbc486 HEAD
bf946c1f3d14b287b2973fdfcca7379415dbc486 refs/heads/master
bf946c1f3d14b287b2973fdfcca7379415dbc486 refs/remotes/dest/master
C:\test-remote\repo3bare>
您只能在存储库之间推送提交和引用。您不能像配置遥控器列表或挂钩脚本或其他存储库元数据那样推送配置信息。 – larsks
啊,我没有意识到这是配置。所以任何遥控器都会出现在'git config --list'中,对吗?如果我可以识别它们,我可以将它们复制并粘贴到另一个存储库的配置中吗?有没有办法只检索与遥控器相关的配置项目? – Kidburla