gitでページを公開する
gitでページを公開できたので説明していきたい。
code:git
bread-is-pan:~ riko$ git clone https://github.com/rikotsuka/rikotsuka.github.io
/* まず、レポジトリーにクローンする,uriの中に入るのは、http,httpsから始まるurlやsshプロトコルで指定するもの、gitoliteなどの他のソフトウェアと連携するもの*/
fatal: destination path 'rikotsuka.github.io' already exists and is not an empty directory.
/*エラーメッセージにかかれている通り、「宛先のパスは既に存在しており、しかも、それは空のディレクトリ(=フォルダ)ではない」から失敗しているだけです。*/
bread-is-pan:~ riko$ cd rikotsuka.github.io
bread-is-pan:rikotsuka.github.io riko$ echo "Hello World" > index.html
/*rikotsukaレポジトリに移動してindex.htmlを読み込む*/
bread-is-pan:rikotsuka.github.io riko$ git add --all
/*git add .と同じ意味合いらしい、ファイルをステージングに追加*/
bread-is-pan:rikotsuka.github.io riko$ git commit -m "Initial commit"
/*ファイルやディレクトリの追加・変更を、リポジトリに記録するにはコミット,最初のコミット*/
gh-pages 03645cc Initial commit
1 file changed, 1 insertion(+), 16 deletions(-)
rewrite index.html (100%)
bread-is-pan:rikotsuka.github.io riko$ git push -u origin master
/*変更情報を記録できたのでpushする*/
Username for 'https://github.com': rikotsuka
Password for 'https://rikotsuka@github.com':
Branch master set up to track remote branch master from origin.
Everything up-to-date
(https://scrapbox.io/meronpanhanzoum-29926234/GIT%E3%81%ABpush%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95)
↑前に書いた記事が参考になる、ローカルのmasterブランチの内容がリモートに送信された、という意味
bread-is-pan:rikotsuka.github.io riko$ git remote add origin https://github.com/rikotsuka/rikotsuka.git
/*リモートにローカルを加える*/
fatal: remote origin already exists.
/*もう存在しているよ!*/
bread-is-pan:rikotsuka.github.io riko$ git commit -m "Initial commit"
On branch gh-pages
nothing to commit, working directory clean
/*git addしてない状態なのでコミットしても何もない状態*/
bread-is-pan:rikotsuka.github.io riko$ git add --all
/*ステージング領域に追加し、gitすべてをコミット対象にする*/
bread-is-pan:rikotsuka.github.io riko$ git commit -m "Initial commit"
/*(ファイルの変更履歴を保存する)コミットする*/
On branch gh-pages
nothing to commit, working directory clean
bread-is-pan:rikotsuka.github.io riko$ git push origin master
Username for 'https://github.com': rikotsuka
Password for 'https://rikotsuka@github.com':
Everything up-to-date
https://gyazo.com/3aac2c0741d3ea0084f28765641e83c8
ー最後にはsetting→page→sourceのBranch master , rootに変更。
上部に記載してあるリンクを押せば、完成。
また、PUSHする前にどうしてgit add -all→git commit ...をやるのかが疑問に思ったのでちょっとまとめる。
/icons/star2.icon
一番最初のgit add --allでファイルのステージングをすべて追加することとなる。
--allだと変更が加えられたファイルと、未追跡だったファイルだけをaddしてくれる。そして新しく出来たファイルのステージングも行う。
そして、git commit -m は新しく出来たレポジトリではなく既存のレポジトリから変更が加えられた時に必要となるためgit addが無いと新しいレポジトリ自体を追加出来ないことが分かった。
/icons/star2.icon
そして、その際にエラーが出たのだが、HTTPでは安全でないためプラグインのHTTPサーバをHTTPSに変えれば解決できるそう。
https://qiita.com/ao_love/items/cc3ad00fc0d7eb5a82a1
https://stackoverflow.com/questions/8465383/loading-http-content-on-https-website
code:html
<script src="https://rawgit.com/phi-jp/phina.js/develop/build/phina.js"></script>
https://gyazo.com/8e3fb20074871aaf195e7c6821efae79
完成した!!
このサイト
→https://rikotsuka.github.io/rikotsuka/?aa
そして映らない可能性として
キャッシュが溜まっている
可能性も考えられる。
また、その後にユーザー名.github.io/レポジトリ名/index.htmlで試してみて映るかを確認する必要がある!!
(参考)
https://qiita.com/Yuki_Yamashina/items/5d8208c450195b65344c
→GITでページを公開する方法
https://pages.github.com/
→やっぱり公式を見るべき!!
https://qiita.com/FiNGAHOLiC/items/d68d19ff9fecc59084e2
http://kimromi.hatenablog.jp/entry/2015/08/04/082357
https://qiita.com/FiNGAHOLiC/items/d68d19ff9fecc59084e2
→git add集
https://qiita.com/mountcedar/items/682743c95fd3b8fc274b
→今さら聞けないGITの使い方
GITでHPを作る時に気をつけること(gitでページを公開するの補足)