Githubã®Project Pagesãä½ãæé ã調ã¹ã¦ã¿ãããããã¯gitã§ç©ºãã©ã³ããä½ãæ¹æ³ã調ã¹ã¦ã¿ãã
http://kanonji.info/blog/2013/12/19/git%E3%81%A7%E7%A9%BA%E3%83%96%E3%83%A9%E3%83%B3%E3%83%81%E3%82%92%E4%BD%9C%E6%88%90%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95/
空ãã©ã³ããä½ããªãã·ã§ã³ã§ããã£ã¨ç°¡åã«ä½ãæ¹æ³ãããã¾ããã
Github pagesã¯ãä»ã¯ãã¦ã¹ã¯ãªãã¯ã§ä½ãã ããããã空ãã©ã³ããä½ãæ¹æ³ãã ãã§ãã
Githubã§ã¯ããã¸ã§ã¯ãã®å
¬å¼ãµã¤ããªã©ã«ä½¿ããProject Pagesãä½æã§ãã¾ããusername.github.com/repo-name
ã¨ããæãã®URLã«ãªããã§ãããæªä½æã®å ´åã¯ç»åã®æ§ãªãä½æã®æé ã表示ããã¾ãã
cd /path/to/repo-name
git symbolic-ref HEAD refs/heads/gh-pages
rm .git/index
git clean -fdx
echo "My GitHub Page" > index.html
git add .
git commit -a -m "First pages commit"
git push origin gh-pages
è¦æ £ããªãã³ãã³ãããã£ã¦ããªã«ãèµ·ãããããåãããªããããã®ã¾ã¾å ¥åããã®ã¯ã¡ãã£ã¨æãã®ã§èª¿ã¹ã¦ã¿ã¾ããã
Caution: make your working directory clean before you do this (either stash or commit), otherwise this will lose any changes you've made to your project since the last commit.
ãã®éãããã®æé ã¯ã¯ã¼ãã³ã°ããªã¼ããå ¨é¨æ¶ããããäºãå ¨é¨ã³ããããã¦ããããstashãã¦ç½®ãããã«è¦åãããã¾ãã
ã¾ã¨ã
ã©ããããã®æé ã¯ã空ã®ãã©ã³ããä½ãæ¹æ³ã®ããã§ããProject Pagesç¨ã§ããgh-pagesãã©ã³ãã«ã¯ãmasterã¨ã¯å
¨ç¶é¢ä¿ã®ç¡ããã¼ã¿ãå
¥ããã®ã§ãåã«masterããæåãããããã©ã³ãã§ã¯ä¸é½åã£ã¦äºã§ãããã¡ãªã¿ã«ãå®ã¯ã¾ã gitã§ãã©ã³ããåã£ãäºãç¡ããã§ãããæ¤ç´¢ãã¦ã¿ãã¨git branch
ã§ã¯ç©ºã§masterã¨åãé¢ããããã©ã³ããä½ãã«ããããã§ãã
git symbolic-ref HEAD refs/heads/gh-pages | HEADãrefs/heads/gh-pages ã«è¨å®ãã |
rm .git/index | ç´¢å¼ãã¡ã¤ã«*1ãåé¤ãã |
git clean -fdx | ã¯ã¼ãã³ã°ããªã¼ã®Untrackedãªãã¡ã¤ã«ã»ãã£ã¬ã¯ããªãåé¤ãã |
解説
ä¸å¿è§£èª¬ãæ¸ãã¾ãããgitãæ·±ãã¨ããã¾ã§ç解ãã¦ãªãã®ã§ãééããåéããå«ãã§ãããããã¾ããã
git symbolic-ref HEAD refs/heads/gh-pages
refs/heads/gh-pages
ããªãã¦å¼ã³æ¹ããããæååãåããã¾ããããããã¯gh-pages
ãã©ã³ãã表ãã¦ããã¯ãã§ãã
$ cat .git/HEAD ref: refs/heads/master $ git checkout -b gh-pages #ããã㯠git branch gh-pages; git checkout gh-pages Switched to a new branch 'gh-pages' $ cat .git/HEAD ref: refs/heads/gh-pages
ãã®æ§ã«æ®éæ¹æ³ã§ãã©ã³ããä½ããã§ãã¯ã¢ã¦ãããããHEADã¯refs/heads/gh-pages
ã«è¨å®ããã¾ããgit branch
ã§ã¯ãå¼æ°ç¡ãã§ã¯HEADããæå®ãã¦ãéå»ã®ãªãã¸ã§ã³ãå
ã«ãã©ã³ããåãã®ã§ã空ã®ãã©ã³ããä½ããªãããã§ãããªã®ã§ã.git/HEAD
ãgit symbolic-ref
ã§å¤ãã¦ãgh-pagesãã©ã³ããä½ãããã§ãããã git branch
ã§ç¢ºèªã§ããã®ã¯ãä½ãããã³ããããããå¾ã§ããã
rm .git/index
.git/HEAD
ãåãæ¿ãã¦ããã¯ã¼ãã³ã°ããªã¼ããã®ä»è²ã
ãªé¨åãmasterã®ã¾ã¾ã§ãããªã®ã§ãã¾ãã¯ç´¢å¼ãã¡ã¤ã«ãåé¤ãã¾ããç´¢å¼ãã¡ã¤ã«ã¯ã調ã¹ãã¨ããååã®éãindexã¨ãstageã¨å¼ã°ãããã®ã®å®ä½ã ã¨æãã¾ããä¾ãã°git add
ãããã¨.git/index
ã«è¿½è¨ããã¦ããã¾ããããã¯ãã¤ããªãã¡ã¤ã«ãªã®ã§ããã®ã¾ã¾è¦ã¦ãããåããã¾ãã((git ls-files
ã§ç¢ºèªåºæ¥ãããã§ãã))ãã©ããã¨ããã.git/index
ã®ä¸èº«ãmasterã®ã¾ã¾ã ã¨ã¾ããã®ã§ãæ¶ãã¾ãã
git clean -fdx
å¾ã¯ã¯ã¼ãã³ã°ããªã¼ã®ãã¼ã¿ãåé¤ããã°ãç¡çããä½ã£ãgh-pagesãã©ã³ãããæ£çæ£éã®ãã©ã³ãã«ãªãã¾ããgit clean
ã¯Untracked fileãåé¤ããã³ãã³ãã§ãããå¤å.git/index
ãæ¶ãã¦ãã¨å
¨é¨Untrackedã£ã¦äºãªããããªããã¨æã£ã¦ã¾ãã
-f | --forceã§ããã©ããªæã«forceããªãã¨ãããªãã®ãåããã¾ãããã»ã»ã» |
-d | Untrackedãªãã£ã¬ã¯ããªãæ¶ã |
-x | ignore ruleãåç §ããå ¨ã¦ã®Untrackedãã¡ã¤ã«ãæ¶ã |
ãªãã·ã§ã³ã¯ãããªæãã§ãããã®æé ã®ä¸ã§ã¯ãè¦ããã«å
¨é¨æ¶ãã£ã¦äºã§ããããrm
ã¨ãã§ãããªãã®ã¯.gitãã£ã¬ã¯ããªãæ¶ããªãããã«ããªï¼
git push origin gh-pagesãªã©ãæ®ã
ã¯ã¼ãã³ã°ããªã¼ã空ã£ã½ã«ãªã£ãããæ¹ãã¦gh-pagesã«ã³ãããããããã¡ã¤ã«ãä½ã£ã¦ã³ããããã¾ããã³ããããã¦åãã¦gh-pagesãã©ã³ãã¯å®éã«ä½ãããããã§ãããã¨ã¯Githubã«pushããããProject Pagesãä½æãããã¯ãã§ãã
[GitHub] Page build successful [repos name]
[GitHub] Page build failure [repos name]
è¨å®æ¬¡ç¬¬ã§ããããããªã¿ã¤ãã«ã®éç¥ãã¡ã¼ã«ã§å±ãã¾ãã
ä½è«ã ãã©ãã©ã³ãåãéãå ´åã®git pushã®ä½¿ãæ¹
ã¨ããã§git push origin/gh-pages gh-pages
ã£ã¦æ¸ããªãã¦è¯ããã ã£ãï¼ãã©ã³ãåã£ããã¨ãªããããã®è¾ºãä¸å®ãã¨æã£ã¦ã¡ãã£ã¨èª¿ã¹ã¦ã¿ããããã¼ã«ã«ã¨ãªã¢ã¼ãã§ãã©ã³ãååããªãããã®ã¾ã¾ã§ããã½ããéãå ´åã¯git push origin
ã£ã¦æãã§æ¸ãã¿ãããorigin/remote ã«ãã¼ã«ã«ã®localãã©ã³ããpushããå ´åã¯git push origin local:remote
ã£ã¦äºããªãå¤åã
Forkããå ´åã®Project Pagesã®ä½ãæ¹
æ¢ã«gh-pagesãã©ã³ããããããã¸ã§ã¯ããForkããå ´åãæåã¯Project Pagesã«ã¢ã¯ã»ã¹ãã¦ãNot Foundæ±ãã§ããããã¼ãã¡ã¤ã«ã追å ããã§ããçå½ã«ãã¡ã¤ã«ãå¤æ´ããã§ãè¯ãã®ã§ãä½ãããã³ããããã¦pushããã¨Project Pagesãä½æããã¾ãããããã¼ãã¡ã¤ã«ã¨ãã³ãããããªãã¦ãä½ãæ¹æ³ãããã®ãããããªããã©ãã¨ããããã
*1:ã¤ã³ããã¯ã¹ãã¡ã¤ã«