Jagannath Krishna.P.A
Jagannath Krishna.P.A

Reputation: 380

How Do I Modify A deployed react.js project on github?

I am currently learning git, GitHub, and react.js. So, I need to host the react.js project in a GitHub domain. So I did some research and deployed the react.js in the GitHub domain. And I deployed the project successfully by doing these steps :

1.I created a GitHub repository.

2.Then I used this code in Terminal: npm install gh-pages --save-dev

3.Then I add this line in the package.json file: "homepage":"http://<github-username>.github.io/<repository-name>" and I added this also in the package.json, scripts:

"scripts": {
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
}

after that i added this also in package.json:

"devDependencies": {
    "gh-pages": "^3.1.0"
  }

4.Then I added remote and committed the code and pushed the code like this:

git remote add origin https://github.com/<github-username>/<repository-name>.git
git add .
git commit -m "initial commit"
git push origin master

5.Then I used this code to deploy the app:npm run deploy

After That Everything was successful and my site hosted as https://<github-username>.github.io/<repository-name>

Then I tried to modify this site, but I can't. When I go to Settings>Pages I found that the deployed branch is gh-pages and this branch wasn't created by me. I changed it back to master and saved it. And when I refreshed the site, there was nothing except the readme.md file. So, I changed it back to gh-pages and it worked again. Then I did some research to modify and I found that I just need to commit and use this code again:npm run deploy

So, I did like That and This Was shown in the Terminal:

> [email protected] predeploy
> npm run build


> [email protected] build
> react-scripts build

'react-scripts' is not recognized as an internal or external command,
operable program or batch file.

What's this all about? I need a solution to modify a deployed react.js app. Anyone Who answers my problem will be appreciated. Thank you 🙏.

Upvotes: 0

Views: 1862

Answers (2)

Jagannath Krishna.P.A
Jagannath Krishna.P.A

Reputation: 380

Just clone the project and create a new branch.

Modify the project. Then add and commit as usual.

Then use the code git pull

And then type git push <your remote name> <the name of the branch you have created early>

Then go to Github and refresh the page. You will see compare pull request button. Click that. Then add title and description. Then click create new pull request. If your branch is mergable, you will go to another page and you will see merge pull request button and click that.That's all. Then You can delete the branch created by yourself by clicking delete branch safely.

Then use the code npm run deploy

I hope this works 😊.

Upvotes: 0

Bona Ws
Bona Ws

Reputation: 356

If I'm not wrong to understand your question, here is my little advice.

You just need to add, commit and push your changes to the master repository, and after that run the following step :

  • npm install
  • npm run predeploy
  • npm run deploy

After the steps are success you need to wait several minutes before the changes are live.

Upvotes: 1

Related Questions