원격 저장소와 모든 브랜치를 새로운 원격 저장소로 옮기고 싶습니다.내 원격 자식 repo 다른 원격 자식 repo로 이동하려면 어떻게합니까?
된 원격 = [email protected]:thunderrabbit/thunderrabbit.github.com.git
새 원격 = 로컬 컴퓨터에서 터미널에서
원격 저장소와 모든 브랜치를 새로운 원격 저장소로 옮기고 싶습니다.내 원격 자식 repo 다른 원격 자식 repo로 이동하려면 어떻게합니까?
된 원격 = [email protected]:thunderrabbit/thunderrabbit.github.com.git
새 원격 = 로컬 컴퓨터에서 터미널에서
그렇다면이 다른 답변들 중 어느 것도 잘 설명되지 않는다는 것입니다. 을 원할 경우 원격 저장소의 br Git의 push
메커니즘을 사용하는 새 리모컨으로 연결하려면 리모컨의 브랜치 각각의 로컬 브랜치 버전이 필요합니다.
git branch
을 사용하여 로컬 분기를 만들 수 있습니다. 그러면 모든 분기 참조가 저장되는 .git/refs/heads/
디렉토리 아래에 지점 참조가 생성됩니다.
그럼 당신은 --all
및 --tags
옵션 플래그 git push
을 사용할 수 있습니다 : 두 번 푸시에있는 이유는 그래서 --all
및 --tags
가 함께 사용할 수 없습니다
git push <new-remote> --all # Push all branches under .git/refs/heads
git push <new-remote> --tags # Push all tags under .git/refs/tags
참고.
여기에 관련 git push
documentation입니다 :
--all
대신 밀어 각 심판 이름의,
refs/heads/
아래의 모든 심판이 추진되도록 지정합니다.refs/tags
에서--tags
모든 심판은 명시 적으로 명령 행에 나열된 refspecs 외에, 푸시됩니다.
--mirror
참고 또한 --mirror
한 번 에 모두 브랜치와 태그 참조를 밀어 사용할 수 있지만,이 플래그의 문제는 .git/refs/
,하지에 모든 참조을 밀어 것입니다 단지 .git/refs/heads
및 .git/refs/tags
일 수 있으며 리모컨으로 푸시하고자하는 내용은 일 수 없습니다. 예를 들어
--mirror
는
git filter-branch
의 부산물입니다 같은
.git/refs/original/
로 이전 원격 (들)
.git/refs/remotes/<remote>/
받고 그뿐만 아니라 다른 참조에서 원격 추적 브랜치를 푸시 할 수 있습니다.
[email protected]:tr/tr.newrepo.git
:
cd ~
git clone <old-remote> unique_local_name
cd unique_local_name
for remote in `git branch -r | grep -v master `; \
do git checkout --track $remote ; done
git remote add neworigin <new-remote>
git push --all neworigin
마지막 줄에 (git push --all gitlab) 오타가 있습니까? gitlab이 아닌 새로운 근원이되어야합니까? –
아, 그렇습니다. 고맙습니다! –
참고로 태그를 푸시하고 싶다면'git push --tags'를 사용해야합니다 ('--all'과 동시에 사용할 수 없습니다). 또한,'git checkout'을 사용하는 대신'git branch'를 사용할 수도 있습니다. 작업 복사본에서 파일을 바꾸지 않으므로 아마 더 빠를 것입니다. –
전체 아이디어는 각 오래된 원격 지사에 대한이다가 않습니다
:
#!/bin/bash
[email protected]:tr/tr.newrepo.git
new_remote=new_remote
[email protected]:thunderrabbit/thunderrabbit.github.com.git
old_remote=origin
git remote add ${old_remote} ${old_remote_link}
git pull ${old_remote}
BRANCHES=`git ls-remote --heads ${old_remote} | sed 's?.*refs/heads/??'`
git remote add ${new_remote} ${new_remote_link}
for branch in ${BRANCHES}; do
git checkout ${branch}
git pull ${old_remote} ${branch}
git push ${new_remote} ${branch} --tags
printf "\nlatest %s commit\n" ${branch}
git log --pretty=format:"(%cr) %h: %s%n%n" -n1
done
당신은 단순히 당신의 origin
저장소의 URL을 변경할 수 있습니다
git clone <old-remote-url> unique_local_name
cd unique_local_name
git pull --all
git remote set-url origin <new-remote-url>
git push --all
이것은 정확하지 않습니다. 각 원격 브랜치의 로컬 브랜치 버전이 없으면 새 리모컨으로 푸시되지 않습니다. '.git/refs/heads /'아래의 로컬 브랜치들만 푸시됩니다. –
이 질문은 자체 답변이지만 질문 자체는 여전히 매우 품질이 낮습니다. 어쩌면 시도한 아이디어 중 일부를 추가하거나 [응답] (http://stackoverflow.com/a/14432237/456814)을보기 전에 살펴본 문서를 추가하십시오. –
FYI, [움라우트의 대답] (http://stackoverflow.com/a/14435630/456814)은 정확하지 않습니다. [내 의견] (http://stackoverflow.com/questions/14432234/how-do- i-move-my-remote-git-repo-to-another-remote-git-repo # comment35718703_14435630). –