git subtree로 github pages배포하기

LeeWonjin·2022년 3월 12일
0

문제해결

목록 보기
3/21

환경 구성

git clone <repo 주소>
* e.g. : git clone https://github.com/wonjinYi/your-repo.git

github에서 repo를 만든 뒤, 로컬에 클론한다. 위 예시의 경우 'your-repo'라는 폴더가 생성된다.

cd <클론된 폴더 이름>
npm i degit
npx degit sveltejs/template <템플릿 생성할 폴더이름>

e.g. :
cd your-repo
npm i degit
npx degit sveltejs/template ./

위 명령으로 스벨트 템플릿 프로젝트를 생성할 수 있다.

빌드

먼저, .gitignore파일에서 public/build줄을 삭제한다.

npm run build

삭제한 이후, 위 명령어로 빌드한다.

git subtree push --prefix public/ origin gh-pages

그 다음 위 명령을 통해 빌드된 파일이 들어있는 public폴더만을 Github repo의 gh-pages브랜치로 push한다. Github repo로 접속해보면 새로운 브랜치 gh-pages가 생긴 것을 볼 수 있다.

pages 설정

https://github.com/wonjinYi/<repo 이름>/settings/pages

위 경로로 접속하여 source는 Branch : gh-pages로 설정한다.

profile
노는게 제일 좋습니다.

0개의 댓글