react環境構築&gitの設定、プッシュ、ブランチ作成切替
react環境構築&gitの設定、プッシュ、ブランチ作成切替
・node.js のーどじぇいえすのインストール
$ node -v バージョンの確認
入ってない→
・インストールのためにHomebrew(ホームブルー)のインストール 公式 https://brew.sh/index_ja
Homebrewはどんなことをする?
Homebrewではアップル(またはあなたのLinuxシステム)が提供していないあなたの必要なものをインストールできます。
以下をターミナルで実行 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
以下をターミナルで実行でnode.jsをインストール % brew install nodejs
・npmのインストール % npm install npm --global
確認 % npm -v
『作りながら学ぶReact』 の内容が古かったみたいでエラーが出てしまうのでこちらを参照 https://qiita.com/rspmharada7645/items/25c496aee87973bcc7a5
$yarn global add create-react-app $create-react-app helloworld Success! Created helloworld at /Users/******/helloworld
作成したプロジェクト配下に移動し、下記のstartコマンドを実行
$cd helloworld $yarn start
Reactの画面が勝手に開き起動成功
helloworld/src配下にあるApp.jsを開き
App.jsの内容を全て消して、以下のようにソースを書いてみる
import React from 'react'; class App extends React.Component{ render() { return ( <div> <h1>Hello World</h1> </div> ); } } export default App;
ブラウザにHello Wordが表示され成功
gitの設定 https://qiita.com/ucan-lab/items/aadbedcacbc2ac86a2b3 https://qiita.com/ucan-lab/items/e02f2d3a35f266631f24#_reference-7cbea668d512073f0df4
$ git config --global user.name "suzukir" $ git config --global user.email "suzukir@colabmix.co.jp"
・.ssh/configに追記
$ vi ~/.ssh/config Host * StrictHostKeyChecking no UserKnownHostsFile=/dev/null ServerAliveInterval 15 ServerAliveCountMax 30 AddKeysToAgent yes UseKeychain yes IdentitiesOnly yes ・global .gitignore 設定(推奨) $ mkdir -p ~/.config/git
git用の鍵を作成
$ ssh-keygen -t ed25519 -N "" -f ~/.ssh/github -C suzukir@colabmix.co.jp Your identification has been saved in /Users/suzukiryosuke/.ssh/github. Your public key has been saved in /Users/suzukiryosuke/.ssh/github.pub. The key fingerprint is: SHA256:n5nidaSBGQ59acyHcPN+UybWLlr4vQyDFwR+2liwDE8 suzukir@colabmix.co.jp The key's randomart image is: +--[ED25519 256]--+ | ..oE | | . =*=+ . | | . o B=o+o +| | o * oBo = | | S .o+o= .| | . B.=.+ | | . B.o+. .| | . o .. + .| | . o | +----[SHA256]-----+
・クリップボードに公開鍵をコピー
$ pbcopy < ~/.ssh/github.pub
鍵の登録
GitHubの公開鍵の設定画面を開く https://github.com/settings/keys New SSH key Title を適当に入力する(PC名を入れておくと鍵管理しやすい) Key にクリップボードにコピーした公開鍵を貼り付ける Add SSH Key で鍵を登録する
・ ~/.ssh/config へ追記
$ vi ~/.ssh/config Host github.com IdentityFile ~/.ssh/github User git
確認 successfully のメッセージが出ていればok。
$ ssh -T github.com The authenticity of host 'github.com (52.192.72.89)' can't be established. RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added 'github.com,52.192.72.89' (RSA) to the list of known hosts. Hi suzukircolabmix! You've successfully authenticated, but GitHub does not provide shell access.
$ git add [ファイル名] $ git commit -m "[コミットメッセージ]" $ git remote add origin [リポジトリのURL] $ git push orgin master $ git add hello_react $ git commit -m "helloreact" $ git remote add origin https://github.com/suzukircolabmix/react.git $ git push -u origin master
プッシュ完了
・VirtualDOM DOM=>Document Object Model
・ブランチを作成からプッシュまで
ブランチは branch コマンドで作成することができる
$ git branch <branchname>
ここでは、issue1という名前でブランチを作成してみましょう。
$ git branch helloreact $ git branch helloreact * master
・ブランチのチェックアウトはcheckoutコマンドで行う
$ git checkout <branch> $ git checkout helloreact % git checkout master % git merge helloreact % git push origin master