Github Pages์ ๋ฐฐํฌ๋ ๊ธฐ์กด portfolio๋ฅผ ๋์ฒดํ๊ธฐ ์ํด์ second ๋ผ๋ ์ด๋ฆ์ ๋ธ๋์น๋ฅผ ์์ฑํ๊ณ , ์์ ์ด ์ด๋ ์ ๋ ๋๋์ second ๋ธ๋์น๋ฅผ master ๋ธ๋์น๋ก ์์ ๋ฎ์ด์ฐ๊ธฐ๋ฅผ ์งํํ๊ธฐ๋ก ํ๋ค.
git checkout second
git merge -s ours master
git checkout master
git merge second
์ ๋ฐฉ๋ฒ๋๋ก ์งํํ๋ค๊ฐ ๋ ๋ฒ์งธ ๋ผ์ธ์์ refusing to merge unrelated histories ๋ผ๋ ์๋ฌ ๋ฌธ๊ตฌ๊ฐ ๋ ์, ์๋์ฒ๋ผ ํด์ฃผ์๋ค.
git checkout second
git merge --allow-unrelated-histories -s ours master
git checkout master
git merge second
์ดํ์๋ readme๋ฅผ ์์ ํ๊ณ commit ํด์ฃผ๋ฉด master ๋ธ๋์น๋ ์๋์ฒ๋ผ ๋ณด์ฌ์ง๋ค.
๊ธฐ์กด second ๋ธ๋์น์ commit ๊ธฐ๋ก์ ๊ทธ๋๋ก ๊ฐ์ง๊ณ ์ค๊ณ ์๋ก ๋ํ readme์ ๋ํ ์ปค๋ฐ ๋ชฉ๋ก์ด ๋ณด์ฌ์ง๋ค. ๊ทธ๋ ๋ค๊ณ ๊ธฐ์กด git ๊ธฐ๋ก์ด ์ฌ๋ผ์ง์ง ์๋๋ค. ์๋๋ second ๋ธ๋์น. master์ ๋ณํฉ์ด ๋์ด์ ์ด์ ์ ์์๋ master ๋ธ๋์น์ ๊น ๊ธฐ๋ก์ ๊ฐ์ง๊ณ ์๋ค.
github pages์ ๋ฐฐํฌํ๊ธฐ / using index.html on the root folder
์ด๋ ๊ฒ ์งํํ๊ณ ๋์ hannah26hannah.github.io/ ๋ก ๋ฐฐํฌ์ํฉ์ ํ์ธํ๋ readme ๋ด์ฉ๋ง ์ถ๋ ฅ๋๊ณ ์์๋ค. root์ ๊ธฐ๋ณธ์ผ๋ก ๋ณด์ฌ์ง ํ์ผ์ธ index.html์ด ๋ถ์ฌํด์, Readme๊ฐ ๋์ ๋ณด์ฌ์ง๊ณ ์์๋ค.
root์ index.html์ ์์ฑํ๊ณ , ์๋ ์ฝ๋๋ฅผ ํ ์ค ์ถ๊ฐํด์ ๋ค์ ์ ๋ก๋ํ๋ค.
<meta http-equiv="Refresh" content="2; url=public/index.html">
์ญ์๋ ์ ๋๋ก ์ ๋ก๋๊ฐ ์ ๋ผ์ gh-pages ํจํค์ง๋ฅผ ์ด์ฉํด์ ๋ค์ ์๋ํ๊ธฐ๋ก ํ๋ค.
github pages์ ๋ฐฐํฌํ๊ธฐ / using gh-pages package
๋ง๋ค์๋ index.html ํ์ผ์ ์ญ์ ํ๊ณ , ์๋ ๋ช ๋ น์ด๋ก gh-pages๋ฅผ ๋ค์ด๋ฐ์์ค๋ค.
yarn add gh-pages --dev
# dev dependency๋ก ์ธ์คํจ ํ๋ค. npm์ ์ด๋ค๋ฉด ์๋ ๋ช
๋ น์ด๋ฅผ ์ด๋ค.
npm install gh-pages --save-dev
package.json ํ์ผ ์ค์ ์ ์๋์ฒ๋ผ ์์ ํด์ค๋ค.
์ฐ์ homepage ํ๋กํผํฐ๋ฅผ ์ถ๊ฐํด์ค๋ค. ๋ง์ผ ๋ค๋ฅธ ์ด๋ฆ์ ์ ์ฅ์๋ฅผ ๊ฐ๋๋ค๋ฉด, <userId>.github.io/<another_repo_name> ํ์์ ๋ฐ๋ฅธ๋ค.
"homepage": "https://hannah26hannah.github.io/",
์คํฌ๋ฆฝํธ๋ predeploy, deploy ๋ผ์ธ์ ์ถ๊ฐํด์ค๋ค. yarn run deploy๋ฅผ ์คํํ๋ฉด predeploy๋ ์คํ๋๋ค.
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
},
์คํ๋๋ฉด ์๋์ฒ๋ผ compile ํ
published ๋ผ๋ ํ ์คํธ๊ฐ ๋จ๋ฉด์ ํ๋ก์ธ์ค๊ฐ ๋ง๋ฌด๋ฆฌ๋๋ค.
CRA์ผ๋ก ๋ฆฌ์กํธ ์ฑ์ ์์ฑํ ๊ฒฝ์ฐ, gh-pages ํจํค์ง ๋งค๋ด์ผ์ ๋ฐ๋ผ ๋น๋๋ฅผ ํ๋ฉด build๋ผ๋ ํด๋์ ๋น๋ output์ด ๋ด๊ธฐ๊ฒ ๋๋๋ฐ, ์ด ์ํ๋ก ๋ค์ homepage์ ์ ์ํด๋ณด๋ ๋ ์ ๋ ์, GIthub Pages ์ธํ ์ master /docs ๋๋ก build ํด๋๋ฅผ docs๋ก renaming ํด์คฌ๋ค. ใ ใ
renaming์ ํ์ ๊ทธ๋ ์ ๋๋ก ๋ํ๋ก์ด๊ฐ ๋๋ค. ์์ฑ๋ build ํด๋์ ์ด๋ฆ์ docs๋ก ๋ฐ๊พธ์ง ์๊ณ ์์ค๋ฅผ ์ฌ๋ฆฌ๋ฉด ์๋์ฒ๋ผ ์๋์ด ๋จ๊ณ ๋ฐฐํฌ์ ์คํจํ๋ค.
์คํฌ๋ฆฝํธ๋ฅผ ์์ ํด์ Renaming ๊ณผ์ ์ ์๋ํํ๊ธฐ๋ก ํด๋ณธ๋ค.
(๊ธฐ์กด์ ์ด ๊ณผ์ ์ ๋ฐ๋ณตํด ๋ฐฐํฌํ๋ค๋ฉด docs ํด๋๊ฐ ์์ ๊ฒ์ด๋ค) -> npm run build ํ build ํด๋๊ฐ ์์ฑ๋๋ค -> docs ํด๋๋ฅผ ์ญ์ ํ๊ณ -> build ํด๋๋ docs ํด๋๋ก ์ด๋ฆ์ด ๋ฐ๋์ด์ผ ํ๋ค.
"scripts": {
"start": "react-scripts start",
"prebuild": "rmdir /s docs",
"build": "react-scripts build && rmdir /s docs && ren build docs",
"rename": "ren build docs",
"test": "react-scripts test",
"eject": "react-scripts eject",
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
},
package.json์ script ๋ถ๋ถ์ ์ด๋ ๋ค. prebuild๋ผ๊ณ ์ด๋ฆ ์ง์ด์ค ๋ถ๋ถ, renmae์ด๋ผ๊ณ ์ด๋ฆ ์ง์ด์ค ๋ถ๋ถ์ ๋์ค์ ๊ฐ ๊ณผ์ ๋ง ๋ฐ๋ก ํ๊ณ ์ถ์ ๋ ์ฐ๋ ค๊ณ ๋ง๋ค์ด๋จ๋ค. ๋น๋ ํ docs ํด๋ ์ง์ฐ๊ณ , ์์ฑ๋ build ํด๋์ ์ด๋ฆ์ docs๋ก ๋ฐ๊พผ๋ค๋ ์๋๋ฆฌ์ค๊ฐ ์ผ์นํ๋ฉด yarn run build๋ง ์คํํ๋ฉด ๋๋ค.
CMD ๋ช ๋ น์ด์ด๊ณ , ๋ฆฌ๋ ์ค๋ฅผ ์ด๋ค๋ฉด “react-scripts build && rm -rf docs && mv build docs” ์ด๋ ๊ฒ ํด์ฃผ๋ฉด ๋ ๊ฒ ๊ฐ๋ค.
How to replace master branch in Git, entirely, from another branch?
I have two branches in my Git repository: master seotweaks (created originally from master) I created seotweaks with the intention of quickly merging it back into master. However, that was three ...
stackoverflow.com