React through Vscode, I want to push an update to github - reactjs

I have a Github repo made, and I have pushed an update before, but I did it with help. I still feel pretty lost, what would be the commands to commit the new update to GitHub through Vscode's terminal?

If you have pushed to the repo before, the following commands should do it:
git add .
git commit -m "your commit message"
git push

Related

Git react folder in Gitlab

I'm going to make a git to my project include spring and react, as shown below:
after I create a local repo and just push this into gitlab as it told me: btw before I git push I have to write "git pull --rebase origin main", otherwise I can't push my repo to gitlab. But I think that is maybe not the reason.
And afterwards it has problem with the react folder in gitlab, and there is no problem with the spring folder, as shown below: I can't open the react folder in gitlab.
So my question was: why only the react folder has this problem but spring not? and how can I fix it? When I open the react folder by vs code, the version control tool also doesn't work when I made some changes.
Very thankful for answering!
why only the react folder has this problem but spring not?
Because delivery-react is probably a nested Git repository (meaning there is a delivery-react/.git), unless you have a .gitmodules file in your main repository.
If you want to add delivery-react as a regular folder:
git rm --cached delivery-react # no trailing /
git commit -m "Remove nested folder"
git add delivery-react
git commit -m "Add deliver-react"
git push

Solution to Keep gh-pages up to day with a master/main branch

I recently build a gh-pages using React and found that my changes in the main branches would not be synced with gh-pages.
Then I found that I don't need to push the whole updates to gh-pages and even to master/main branch for updating my site. In order to see updates on my git page, I ran npm run deploy using Vscode on the main branch then just wait for a few minutes to see updates on my gh-pages."
Simple Solution: enter npm run deploy on the master/main branch then wait a few minutes to see updates showing on your gh-pages and your site on github pages
Below is a suggested solution but it's not working for me.
`$ git add .`
$ git status // to see what changes are going to be commited
$ git commit -m 'Some descriptive commit message'
$ git push origin master
$ git checkout gh-pages // go to the gh-pages branch
$ git rebase master // bring gh-pages up to date with master
$ git push origin gh-pages // commit the changes
$ git checkout master // return to the master branch
Hope this post can help. Thank you.
Resolve the syncing issue between gh-pages and master/main branch in GitHub. This issue refers to the updates made in master/main branch are not synced to gh-pages.
Simple Solution: enter npm run deploy on the master/main branch then wait a few minutes to see updates showing on your gh-pages and your site on github pages

How to handle git and react project for the first time?

I've installed a react project recently this way:
npx create-react-app projectName
When it successfully installed, apparently the git is also installed on it. Since there is .git directory exist in the root.
From the other side, I created a new project on Gitlab and connected it to the project this way:
git remote add origin http://gitlab.<domain>.com/myName/projectName.git
Now, I want to push a commit on the git named something like "Project Init". But there is no change detected when I run git status. So I cannot add and commit anything.
So, when I run git push origin master I get this error:
hint: 'git pull ...') before pushing again.
When I run git pull origin master, get this error:
fatal: refusing to merge unrelated histories
I stuck in this part ..! What I have to do? In other word, how to synchronise the git and a react project created just now?
Correct way to do it is to create new repo without "initial readme.md commit". Fast way is to git push origin main --allow-unrelated-histories. Or just simply use --force flag in push, but be careful with that
You can use the allow-unrelated-histories flag when pushing.

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:
> sample#0.1.0 predeploy
> npm run build
> sample#0.1.0 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 🙏.
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.
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 😊.

How do I publish my react app on github properly?

I am trying to publish my react app on github.Here are the steps that I have followed.
1-I have installed git on my windows.
2- In Visual Studios terminal I have written git init
3-Then I have created a repository on github called "cartdemo"
4-In my package.json I have changed homepage, made the private false and added "deploy": "gh-pages -d build
5- Again in VS terminal I have written git add .
6-git commit -m "Go Live"
7-git remote add origin https://github.com/rahman23/cartdemo.git
8-git push
Note: Here you can see the files https://github.com/rahman23/cartdemo
However when I hit the link https://rahman23.github.io/cartdemo/ I get a page where it is written
cartdemo
This project was bootstrapped with Create React App.
Available Scripts
In the project directory, you can run:
npm start
Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.
The page will reload if you make edits.
You will also see any lint errors in the console.
Where did I do wrong?
In step 8, you need to tell git which repo and branch to push the project to. Since you added an origin, you would...
git push origin master
Since the project has now been pushed, add this to your package.json file.
"homepage" : "http://rahman23.github.io/cartdemo"
then run:
yarn build in the console, and try pushing it again...

Resources