본문 바로가기
GIthub

[Github] 하나의 Repository에 여러 개의 프로젝트 업로드(Git Subtree)

by jelliclesu 2024. 7. 9.

하나의 Repository에 여러 개의 프로젝트 업로드

 

Spring 공부하면서 프로젝트 하나 만들 때마다 업로드되면 너무 쓸데없이 많아지고 지저분해질 것 같아서

하나의 Repository에 여러 프로젝트를 생성하려고 이렇게 저렇게 시도해봤는데,,

자꾸 Reject 뜨면서 절대 안되고, 계속 생성하고 지우고 반복하다가 찾아보니까

subtree를 이용하는 방법이 있길래 정리해보려고 합니다!

 

  1. GitHub에 하나의 빈 Repository 생성
    • 여러 프로젝트를 담을 부모 Repository 가 됨
  2. 부모 Repository clone
    • GitHub Code 에서 주소 Copy 
    • Terminal에서 clone
      git clone 부모Repository주소
  3. 부모 Repository로 이동
    cd 부모Repository이름
  4. subtree 이용해 부모 Repository에 자식 Repository 넣기
    git subtree add --prefix=폴더명 자식Repository주소 branch이름
    • 폴더명은 부모 Repository에서 보여질 폴더명
    • 자식Repository주소는 GitHub 주소를 뜻하기에 이미 GitHub에 자식 Repository가 존재해야 함
    • ⚠️이때 부모 Repository 아무 commit이 없는 경우 오류 발생
      더보기
      ambiguous argument 'HEAD': unknown revision or path not in the working tree
      • commit 메시지 생성
    • git commit --allow-empty -n -m "커밋메시지"
  5. GitHub에 push
    git push origin main
    • ⚠️로그인 과정에서 오류 발생
      더보기
      remote: Support for password authentication was removed on August 13, 2021. remote: Please see https://docs.github.com/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
      • GitHub에서 Settings >  Devloper setteings > Personal acces tokens > Tokens (classic) 클릭 후 Token 생성
        • repo
        • admin:repo_hook
        • gist
        • user
        • delete_repo
      • 생성된 Token 복사
      • Teminal에서 다시 push 한 후, password 입력란에 복사한 Token 입력!
  6. 부모 Repository에 자식 Repository 파일 형식으로 생성 완료
    • 정상적으로 업로드가 완료되었으면, 기존 자식 Repository는 삭제해도 됨
  7. 이후에는 자식 Repository 넣는 부분만 해주면 됨(부모 Repository 생성 없이)

 

<참고 링크>

https://hy-ung.tistory.com/86

 

[Git hub] 하나의 Repository에 여러 프로젝트 올리기

한개의 레포지토리에 여러 프로젝트를 생성하여 프로젝트를 진행 하고자 했다. 인텔리제이에서는 한개의 프로젝트에서 여러 프로젝트가 생성이 되었지만, 이것을 깃허브에 Push 하는 과정에서

hy-ung.tistory.com

https://velog.io/@049494/하나의-리포지토리에-여러-프로젝트-올리기

 

# 하나의 레포지토리에 여러 프로젝트 올리기

과제를 여러개 올리는 경우, 각각 리포지토리를 만들면 너무 갯수가 많아지므로 하나의 리포지토리에서 여러 프로젝트를 관리해야할 필요성이 생긴다. 👉🏻 리포지토리 안에 여러 폴더를 만

velog.io

https://hyeo-noo.tistory.com/184

 

[Mac] GitHub push token 오류 해결

Github 오류 7.29일 새벽 갑자기 git push가 안 되는 현상을 겪었다. 오류의 첫 줄이 무슨 말이냐면 Password 인증방식이 일시적으로 brownout(shutdown?)되었다. Password 대신에 personal access token을 사용해주세

hyeo-noo.tistory.com