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.
Related
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
How to add React to an existing Electron app?
I have a CLI Node.js application to which I'm intending to add a desktop GUI using ElectronJS and React. I now have succesfully combined the original CLI app and Electron so that when I run npm start an Electron powered window pops up and the old app starts doing its thing. Is there an easy way to add React to the stack or do I need to start my project over with this new architecture in mind?
Now when I go to the root directory of my project and try to npx create-react-app it refuses to initialize because there's already stuff in there. If I create a new subdirectory to my project in which I would then initialize the React app then I'd have node_modules, package.json etc. duplicates and a weird layered structure which probably isn't the recommended way to go about if it would even work...
Create a subdirectory and run create-react-app there. Afterwards, just move the contents up a directory and delete the empty directory.
Example:
cp package.json package.json.backup
mkdir temp
cd temp
npx create-react-app test-app
mv test-app/* ..
cd ..
rm -fr temp
You can run the above commands in Git Bash if you're on Windows.
Afterwards, you will want to manually merge the package.json from create-react-app with your old one that's now called package.json.backup.
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
This is clearly something I'm misunderstanding but I'm desperately struggling to find an answer.
I've been teaching myself React with create-react-app, I've run "npm run build" to spit out my finished project, and I have the project pushed to a private bitbucket repo.
My expectation would be to then SSH to my server, and git clone the /build directory in order to make this project live. Obviously that is possible (if I removed /build from .gitignore), but since the /build directory is in .gitignore this clearly isn't the intended/desired behaviour.
So, my question is - what is? How does one publish a completed build to server without pulling from git (and obviously without FTP)?
Thanks!
The build directory is in .gitignore as it can be generated from the existing files.
To minimize upload/download time only essential items should be kept in the git repo. Anything that can be generated need not be in the repo (The build directory in this case).
If you are working on a server that has node (AWS, Heroku etc) you can git clone the entire repo on the server and then run npm run build there (after npm install). Then you can do something like
npm install -g serve
serve -s build
The serve module serves static files and you pass the build folder as a parameter.
If you are working on a more old style server like Apache static hosting with cPanel etc then you will need to upload the entire build directory containing static files and index.html.
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