m_shige1979のときどきITブログ

プログラムの勉強をしながら学習したことや経験したことをぼそぼそと書いていきます

Github(変なおっさんの顔でるので気をつけてね)

https://github.com/mshige1979

GithubにWebページとして使用する

Githubについて

ほとんど初心者

gitはなんとかブランチを作成したり、チェックアウトとかできる
今回はプルリクエストとかやったけど実際ほとんどわかっていない

2段階認証したらパスワード認証では通らない

よって「Personal Access Tokens」で個別のパスワードを生成して対応する

なんか「xxxx.github.io」?みたいなサイトあるけど何なのかな?

ちょっとgoogle先生に聞いてみたらGithubでWebサイトを作っているみたい
phpとかは動かせんけど、静的なページが作成できるよう。

なんか便利そうなんでやってみる

とりあえず準備

先にgithubとかのアカウントを作成し、top画面よりAccount settingsへ移動する

f:id:m_shige1979:20131206232509j:plain

「Organizations」をクリック

f:id:m_shige1979:20131206232518j:plain

「Create new organization」をクリック

f:id:m_shige1979:20131206232527j:plain

Organizationの名前とメールアドレスを入力して、作成ボタンを押下

f:id:m_shige1979:20131206232535j:plain

「finish」を押下

f:id:m_shige1979:20131206232545j:plain

「New repository」を押下

f:id:m_shige1979:20131206232552j:plain

リポジトリ名にxxx.github.comとして、「Create repository」を押下

f:id:m_shige1979:20131206232559j:plain

準備が完了

f:id:m_shige1979:20131206232606j:plain

ファイルを公開

環境はなんでもいいと思うけど今回はeclipseでプロジェクトを用意

f:id:m_shige1979:20131206233036j:plain

リポジトリのクローンを作成して、いろいろやる
# ディレクトリ移動
$ cd /c/pleiades_works/pleiades_PDT/xampp/htdocs/mshige1979-web.github.com/

# cloneを作成
$ git clone https://github.com/mshige1979-web/mshige1979-web.github.com.git .
Cloning into '.'...
warning: You appear to have cloned an empty repository.

# ファイルを作成
$ echo "aaaa" > index.html

# インデックスに追加
$ git add index.html
warning: LF will be replaced by CRLF in index.html.
The file will have its original line endings in your working directory.

# コミット
$ git commit -m "init"
[master (root-commit) 279e86d] init
warning: LF will be replaced by CRLF in index.html.
The file will have its original line endings in your working directory.
 1 file changed, 1 insertion(+)
 create mode 100644 index.html

# プッシュ
$ git push -u origin master
Username for 'https://github.com': メールアドレス
Password for 'https://メールアドレス@github.com': アクセストークンパスワード
Counting objects: 3, done.
Writing objects: 100% (3/3), 211 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/mshige1979-web/mshige1979-web.github.com.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.

# ブランチを作成
$ git branch gh-pages

# ブランチを切り替え
$ git checkout gh-pages
Switched to branch 'gh-pages'

# プッシュ
$ git push -u origin gh-pages
Username for 'https://github.com': メールアドレス
Password for 'https://メールアドレス@github.com': アクセストークンパスワード
Total 0 (delta 0), reused 0 (delta 0)
To https://github.com/mshige1979-web/mshige1979-web.github.com.git
 * [new branch]      gh-pages -> gh-pages
Branch gh-pages set up to track remote branch gh-pages from origin.
サイトへアクセス

f:id:m_shige1979:20131206233457j:plain

Githubについて

Githubを使用する人には常識なのかよくわかりませんが、なんかプルリクエストしないと画面に反映されないようです。
なんかいろいろなところでマージしたりコンペアしたりしてよくわからないけど今回はちょっと手間がかかる事は記載しておきます

ちょっとAngularを追加

今現在は以下

f:id:m_shige1979:20131206233755j:plain

参考

ひしだま's 技術メモページ
http://www.ne.jp/asahi/hishidama/home/tech/git/gh-pages.html

そーだいなるらくがき帳
http://soudai1025.blogspot.jp/2012/07/github.html

Github Pages
http://pages.github.com/

まとめ

Githubで静的なWebサイトを用意できた。Angularのサンプルページは別の場所にその内移動するけど使えそうになった。
javascriptなどのデモサイト用に使用してみよう。

あと、githubのプルリクエストの仕組みをちゃんと理解しなくては…

作ったGithubページ

http://mshige1979-web.github.io/