GitHub Repository들 하나로 합치기 (subtree)

2024. 9. 22. 14:22·🔧 Dev Tools & Environment/🔄 Version Control
반응형

GitHub Repository들 하나로 합치기 (subtree)

나 같은 경우에는 공부용으로 만든 Repository들이 많아 이걸 하나로 정리하고 싶었다.

1. 준비 단계

  • 병합할 모든 Repository의 목록을 만든다.
  • 각 Repository의 구조를 검토하고 충돌 가능성을 확인한다.
  • 중요한 데이터는 백업해둔다.

2. 새 Repository 생성

GitHub에서 새로운 빈 Repository를 생성한다.

이 Repository가 모든 프로젝트를 통합할 대상이 된다.

3. 새 Repository 클론

새로 생성한 Repository를 로컬 시스템에 클론한다.

git clone <Repository url>
cd <프로젝트 폴더 위치>

Repository를 생성때 Readme 생성에 체크를 하지않았다면 first commit이 존재하지 않을 것이다.
아래의 명령어를 통해 first commit을 해주자!

echo "# spring-study" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M master
git remote add origin <Repository url>
git push -u origin master

4. Repository 합치기

git subtree add --prefix=<기존레포지토리명> <기존레포지토리주소> <기존메인브랜치명>

성공적으로 subtree가 추가되었다.

git tree를 봤을 때 해당 레포가 추가된걸 볼 수 있다.

5. 원격 저장소로 push

메인 브랜치명이 master일경우 HEAD:master로 바꿔주면 된다.

git push origin HEAD:main

6. 기존 Repository 삭제

이제 불필요해진 기존 repository를 삭제하면 된다.

반응형

'🔧 Dev Tools & Environment > 🔄 Version Control' 카테고리의 다른 글

Dependabot으로 의존성 관리 자동화하기  (2) 2025.07.09
'🔧 Dev Tools & Environment/🔄 Version Control' 카테고리의 다른 글
  • Dependabot으로 의존성 관리 자동화하기
KilPenguin
KilPenguin
penguin-dev 님의 블로그 입니다.
    반응형
  • KilPenguin
    Penguin Dev
    KilPenguin
  • 전체
    오늘
    어제
    • 분류 전체보기 (41)
      • 🏗️ Architecture & Design (2)
        • 📐 Clean Architecture (2)
        • 🔄 Design Patterns (0)
      • ⚡ Performance & Optimizatio.. (4)
        • 🗄️ Database Tuning (2)
        • 🚀 Caching Strategy (1)
        • 🖥️ Server Optimization (1)
      • 💻 Backend Development (9)
        • 🔒 Concurrency Control (5)
        • 🌱 Spring Framework (3)
        • 📨 Event-Driven Architecture (0)
        • ☕ Java Fundamentals (1)
      • 🔧 Dev Tools & Environment (4)
        • 🔄 Version Control (2)
        • 📝 Documentation Tools (1)
        • 🎨 Blog Setup (1)
      • 📈 Career & Growth (21)
        • 🎓 Learning Journey (15)
        • 🎤 Conference & Community (6)
      • 🎯 Personal (1)
        • 👋 Introduction (1)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    인프런
    개발바닥밋업
    항해플러스
    항해99
    항해플러스후기
    항해솔직후기
    항해플러스백엔드
    판교퇴근길밋업
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.4
KilPenguin
GitHub Repository들 하나로 합치기 (subtree)
상단으로

티스토리툴바