0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

GitとGitHubを基本からまとめてみた【GitHub Pages (React)】

Last updated at Posted at 2021-10-20

Create React App でアプリの雛形を作成

$ npx create-react-app <アプリ名>
$ cd <アプリ名>
※ 必要のないファイルは削除する。

Githubでリポジトリを新規作成

(1) GitHubにアクセスし、ログインする。ページ右上の『+』アイコンをクリックし、『New repository』をクリックする。
(2) 『Repository name』を記入し、『Create repository』をクリックする。
(3) 作成したアプリをデプロイする

$ git init
$ git remote add origin 例:https://github.com/username/username.github.io
$ git add .
$ git commit -m "コミットメッセージ"
$ git push origin master

(4)Github pagesをインストールする。

$ npm install gh-pages --save-dev

(5)Reactアプリのpackage.jsonを修正する。

 package.json
//...
"homepage": "https://[GitHub username].github.io/[created repository name]/",
//...
"scripts": {
    "deploy": "npm run build && gh-pages -d build"
  },
//...

(6)Githubにリポジトリを作成してデプロイする

$ git@github.com:[GitHub username]/[Repository name].git
$ git push -u origin master
$ npm run deploy

※ GitHubにアップロードを出来たか確認する。

GitHubPageを設定

(1) Github 『Settings』  をクリックし、Github Pagesの『master』を選択し、『save』を押す。
(2) その後下へスクロールしGitHub Pages のSourceをgh-pages branchへ変更する.
(3) GitHubPages設定後表示もう一度GitHubPagesの設定場所へ移動し表示されているURLをクリックし、画面を確認する。

参考サイト

[React 最初からデプロイまで① GitHub Pages編]
()
[github-pageにReact appをデプロイしてみた]
(https://qiita.com/Ham4690/items/4535d744a78db9e403d7)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?