Git react folder in Gitlab - reactjs

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

Related

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.

Can't add React project to Git repo

Currently working on a React app for a school project and need to be able to share the code with my team. I created the app using npx create-react-app app-name. I then try to add app-name to GitHub however I get the following:
hint: You've added another git repository inside your current repository.
hint: Clones of the outer repository will not contain the contents of
hint: the embedded repository and will not know how to obtain it.
Why can't I add this folder to GitHub like a regular folder? Is there a better way to share a React app with the team?
Thanks
Looks like you have 2 repos. Did you run git init more than once?
I would look in your project code for any .git folders and delete them.
This command will show you any git related files and folders:
find . -type d -name ".git" \
&& find . -name ".gitignore" \
&& find . -name ".gitmodules"
Move to your root project directory and run git init again.

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...

Hugo theme not rendering when built

I have a Hugo site using the hyde-hyde theme.
When I serve the site with hugo serve -D, I can view the site with the expected theme:
When I build the site to the public directory with command git submodule init && git submodule update && hugo version && hugo and open the site, the theme markup is missing?
Does anyone know what I'm doing wrong?
Note: I added the theme as a submodule to the themes directory.
At the beginning of config.tohml, you need to specify your real domain name,
because after the assembly all files will be searched in the root of this address (replace "example.com" with the domain name)
Instead of using a 1-line command, I would advise to do it step by step.
The problem might be with git submodule update. The main common error I face when using this command is that git asks me to commit the complete distribution, and refuse to update the submodule if I have uncommited changes.
To bypass this behavior, you can try the following commands:
git submodule update --remote
git submodule update --remote --force
Or the problem might be with hugo
Try the following command to have more info on what is happening:
hugo --log --verbose

How to quickly deploy React / Redux app as a sample?

It seems one way is to deploy the React app to Heroku, but is there a simple way to deploy to our own website or to GitHub page feature so that you can see the page off from GitHub? (just as a sample, not for production)
Details:
It seems that one possible way may be to use
wget -r --no-parent http://localhost:8080 -P sample -nH
cp -rf images any_needed_folder sample
and now you can git add sample and git commit and push to github and turn on the GitHub page for your repo and be able to see your React app inside of sample.
You also need to change the paths in the index.html, from /bundle.js to bundle.js, etc, because you need relative path instead of going to the root of your website.
(I used wget to recursively download index.html, bundle.js, and style/ (the CSS files) because bundle.js cannot be found in the whole directory on the local hard drive. I used wget because curl doesn't seem to be able to download recursively)
Ok, I found that the latest React, it will tell you to use
create-react-app hello-world
to create the app, and then there is an official
npm run build
to build it to host it as a Gthub page, or on your own website.
If wget is doing what you want, cool, use that.
For the actual deploying, I recommend using gh-pages on npm. It handles creating an orphan branch and copying your output files into it, and then pushing all in one command.
Install it:
npm install --save-dev
And in an npm script:
gh-pages -d sample

Resources