Skip to content
kitiya edited this page Jul 12, 2020 · 9 revisions

Git Branching

Creating a new branch & switching branches | Link

$ git branch <branch>
$ git checkout <branch>

$ git checkout -b <branch> // create and checkout

Push a new local branch to a remote Git repo | Link

$ git remote add origin <https://github.com/user_name/project_name.git>
$ git push -u origin <branch>

Other Git Commands

$ git config user.email

Merge a Git branch into master | Link

The best (and safest) way to merge a Git branch into master:

$ git checkout master
$ git pull origin master
$ git merge test
$ git push origin master

Step 1: Add homepage to package.json

Create React App uses the homepage field to determine the root URL in the built HTML file.

"homepage": "https://myusername.github.io/my-app",

Step 2: Install gh-pages and add deploy to scripts in package.json

Now, whenever you run npm run build, you will see a cheat sheet with instructions on how to deploy to GitHub Pages.

To publish it at https://myusername.github.io/my-app, run:

npm install --save gh-pages

Add the following scripts in your package.json:

"scripts": {
+   "predeploy": "npm run build",
+   "deploy": "gh-pages -d build",
    "start": "react-scripts start",
    "build": "react-scripts build",

The predeploy script will run automatically before deploy is run.

Step 3: Deploy the site by running npm run deploy

npm run deploy

Step 4: For a project page, ensure your project’s settings use gh-pages

Finally, make sure GitHub Pages option in your GitHub project settings (in the source section) is set to use the gh-pages branch:

Step 5: Run npm run deploy after new changes

Gh-pages deployment problems with react-router

Clone this wiki locally