Moving git repository and all its branches

2022. 12. 16. 16:45·개발노트/기타
반응형
모든 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
'개발노트/기타' 카테고리의 다른 글
  • git-crypt (git 암호화) 사용해보기 (Mac)
  • git head 사라짐;; (유실된 커밋 복원)
Jeck Lee
Jeck Lee
Android까지의 정복을 노리고 있는 iOS 앱 개발자입니다
  • Jeck Lee
    쩩쩩노트
    Jeck Lee
  • 전체
    오늘
    어제
    • 분류 전체보기 (39)
      • 개발노트 (37)
        • iOS (17)
        • Android (1)
        • Flutter (15)
        • JavaScripit (1)
        • 기타 (3)
      • 자유노트 (2)
        • 이 앱 저 앱 사용기 (1)
  • 인기 글

  • 최근 글

  • 링크

    • 쩩깃
  • 태그

    Android
    Xcode
    sns login
    Swift
    APPLE LOGIN
    git
    ios
    SwiftUI
    Flutter
    Firebase
  • «   2025/06   »
    일 월 화 수 목 금 토
    1 2 3 4 5 6 7
    8 9 10 11 12 13 14
    15 16 17 18 19 20 21
    22 23 24 25 26 27 28
    29 30
    250x250
  • hELLO· Designed By정상우.v4.10.1
Jeck Lee
Moving git repository and all its branches
상단으로

티스토리툴바