2016-11-04 3 views
0

push-to-empty와 clone-mirror를 사용하면 커밋뿐만 아니라 새로운 저장소로 많은 것을 보낼 수 있다는 것을 알고 있습니다. 예를 들어 원격 지점을 복사 할 수 있습니다. 리모컨을 통해 전송할 방법이 있습니까?리모컨을 리모컨으로 밀어 넣을 수 있습니까?

특히 복제 미러를 사용하면 직감적으로 다른 저장소의 모든 것을 반영한다고 생각했습니다. 그래서 나는 이것이 리모컨을 포함하지 않는 것 같아서 놀랐다.

아래의 예에서는 두 개의 리모컨 "dest"와 "blah"로 repo ("repo1")를 가져 와서 새로운 베어 리포지토리 "repo2"(push-to-empty)로 푸시했습니다. 나는 또한 동일한 "repo1"을 가져 와서 "repo3"에 복제했다. "repo2"의 경우, 원격 또는 원격 참조가 푸시되지 않았습니다. "repo3"의 경우, "dest"원격에 대한 원격 참조가 복사되었습니다 (주의 :이 분기는 내가 추적 할 때 "repo2"를 밀어 넣었을 때 존재하지 않았습니다). 다른 원격 ("어쩌구")의 추적. 당신은 먹이를이 사용할 수

remote.origin.url [email protected]:larsks/oschecks.git 
remote.origin.fetch +refs/heads/*:refs/remotes/origin/* 

: 뭔가를 생산할 예정이다

git config --get-regexp '^remote\.' 

:

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> 
+0

리포지토리간에 커밋과 참조 만 푸시 할 수 있습니다. 리모컨 목록이나 훅 스크립트 또는 기타 저장소 메타 데이터와 같은 구성 정보를 푸시 할 수 없습니다. – larsks

+0

아, 구성인지 알지 못했습니다. 그래서 어떤 원격 장치도'git config --list'에 나타날 것입니다, 맞습니까? 내가 그들을 식별 할 수 있다면, 복사해서 다른 저장소의 설정에 붙여 넣을 수 있을까요? 리모컨과 관련된 구성 항목 만 검색 할 수있는 방법이 있습니까? – Kidburla

답변

2

당신은 git 다음과 같이 로컬 저장소와 관련된 리모컨의 목록을 얻을 수 있습니다 이 스크립트를 git config (그리고 원격 저장소의 내용을로드하는 데 아마도 git remote update)으로 보내면됩니다.

관련 문제