반응형
모든 local&remote branch를 다른 git repository에 복사하기
팀 플젝 등을 하다보면 개인 계정이 아닌 공용 계정 깃에 작업을 하게 되는데, 개인 깃에도 히스토리 백업하고 싶었다.
-> 절차는 https://gist.github.com/niksumeiko/8972566 링크 참고했음
보면 주석까지 멋지게 달아주셨으므로 읽어가면서 필요한 부분 따라하면 되는데 나는 아래 플로우만 시행
1. 모든 branch & tag fetch
2. new remote origin 추가 (이 부분만 위 링크와 다름)
3. new origin에 모든 branch push
# Fetch all of the remote branches and tags:
git fetch origin
# Add a "new repo" as a new remote origin:
git remote add new-origin https://[계정이름]:[personal token]@github.com/[계정이름/~.git(repository 경로)]
### 만약 잘못 추가했을 경우 삭제:
# git remote remove new-origin
### remote 확인:
# git remote -v
# Push all local branches
git push --all new-origin
# Push all tags:
git push --tags new-origin
-끗!-
+)
나는 기존의 공용깃도 계속 쓸 거니까 이건 안 하고 냅뒀는데, 링크 내용(아래 코드)처럼 기존 origin을 삭제해주면 clone이 아니라 move가 된다
# Remove "old repo" remote:
git remote rm origin
# Rename "new repo" remote into just 'origin':
git remote rename new-origin origin
-진짜 끗!-
728x90
반응형
'개발노트 > 기타' 카테고리의 다른 글
git-crypt (git 암호화) 사용해보기 (Mac) (1) | 2024.11.19 |
---|---|
git head 사라짐;; (유실된 커밋 복원) (0) | 2022.12.25 |