2011-04-11 4 views
38

git push origingit push my_other_remote을 같은 줄에 입력하고 싶습니다. 가능한?힘내 : 하나의 명령으로 두 개의 리포지셔로 푸시

+0

표준 명령을 사용하여이 작업을 수행 할 수 있다고 생각하지 않지만'git-multipush' 또는 그 밖의 것을 쓸 수 있습니다. –

+0

[여러 원격 위치에서 끌어 오기/밀어 넣기] 가능한 복제본 (http://stackoverflow.com/questions/849308/pull-push-from-multiple-remote-locations) – techraf

답변

84

origin 리모컨에 추가 푸시 URL을 추가하여 동일한 효과를 얻을 수 있습니다. 예를 들어, 기존 리모컨의 URL이있는 경우 다음과 같이

$ git remote -v 
origin [email protected]:something.git (fetch) 
origin [email protected]:something.git (push) 
my_other_remote git://somewhere/something.git (fetch) 
my_other_remote git://somewhere/something.git (push) 

당신은 할 수 :

git remote set-url --add --push origin git://somewhere/something.git 

그런 다음, git push origin 모두 저장소에 밀어 것입니다. 그러나 혼동을 피하기 위해 both이라는 새 리모콘을 설정하는 것이 좋습니다. 다음

git remote add both [email protected]:something.git 
git remote set-url --add --push both [email protected]:something.git 
git remote set-url --add --push both git://somewhere/something.git 

... : : 예를 들어

git push both 

은 ... 모두 저장소에 밀어하려고합니다.

+0

이것은 원격/원본 및 'remote/my_other_remote'는 분기를 추적합니까? –

+0

@ Paŭlo Ebermann : 두 가지의 URL이 푸시 URL로 추가되는 상황에서 'refs/remotes/origin/master'및 'refs/remotes/my_other_remote/master'가 둘 다 업데이트 될 것이라고 제안했습니다. '원산지'로 바꾸면'git push origin'이됩니다. –

+0

이것은 아마도 내가 찾고있는 것처럼 보입니다.하지만 저는 여전히 약간 혼란 스럽습니다 ... 내 앱을 Heroku와 BitBucket에 맡기고 싶다면 진행하는 법? 먼저 Repo를하고 Heroku를 방문한 다음 BitBucket에 repo를 작성하는 것과 같은 방법으로 만들거나 올바른 방법이 무엇입니까? – user984621

10

당신은하여 .git/config 파일에 다음과 같이 넣을 수 있습니다 :

[remote "both"] 
    url = url/to/first/remote 
    url = url/to/other/remote 

이제 git push both를 사용하여 두 개의 URL을 푸시 할 수 있습니다.

당신은 또한 당신의 .git/config 파일에 다음 줄을 추가 할 수 있습니다 (동기에 유용) 그들로부터를 가져 하려면

:

[remotes] 
    both = origin, other 

이제 당신은 또한 git fetch both를 실행할 수 있습니다.

+6

은 Mark의 것과 기본적으로 동일한 솔루션입니다 (수동 편집을 통해 수행하는 경우를 제외하고) 또는 다른 차이점이 있습니까? –

+2

차이가 없습니다. – silvio

관련 문제