++ 요즘은 Netlify나 Vercel이 쉽고 잘 되어있으므로 그걸 이용하길 추천드립니다.
react를 사용 가능하다는 전제하에 작성합니다.
1. 원하는 폴더에 react 프로젝트 생성
npx create-react-app portfolio
2. GitHub Desktop에서 레퍼지토리 생성
File -> Add Local Repository -> 생성한 프로젝트 경로 선택
3. Publish repository 클릭
Keep this code private 체크 해제
4. github 페이지에 레퍼지토리 생성된것 확인, 만약 private로 레퍼지토리 생성했다면 public으로 변경
GitHub: Let’s build from here
GitHub is where over 100 million developers shape the future of software, together. Contribute to the open source community, manage your Git repositories, review code like a pro, track bugs and fea...
github.com
레퍼지토리 public으로 변경방법
Settings -> Danger Zone -> Change repository visibility
5. gh-pages 설치
생성한 프로젝트 폴더로 이동 후
npm i gh-pages
6. package.json 수정
제일 위에 homepage 내용 추가하고 (자신의 내용으로 변경), scripts에 predeploy, depoly 추가
homepage 내용 예시) "homepage": "https://SpringDream0406.github.io/portfolio",
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
7. 배포
npm run deploy
8. 홈페이지 주소로 적었던 주소로 접속해보기
배포의 경우 딜레이가 있을 수 있으니 조금 있다 접속해보기
홈페이지 주소를 직접 입력하는 방법 말고도
github 홈페이지 -> Settings -> Pages
에 가보면 상단에 배포 주소와 언제 배포했는지가 나오며, 배포한 사이트 방문하기 버튼역시 있음.
'코딩 > Git' 카테고리의 다른 글
변경사항이 제대로 반영 안될 경우 / 특정 파일 삭제하기 (0) | 2024.05.18 |
---|---|
협업을 위한 git 커밋컨벤션 설정하기 (0) | 2024.05.12 |
README 작성하기 (0) | 2024.03.14 |
commit 수정/삭제하기 (0) | 2024.02.27 |
Git 초기 설정 (0) | 2024.02.08 |