Using git repositories with WebStorm and React
Hi,
I have created a new React project with WebStorm. WebStorm automatically created the git repository. I can see, that except node-modules all other directories and files are in the local git repository. (.idea and .gitignore are also there.) This project is on Linux. I would like to use a shared bare git repository (like GitHub) to work on this project both from Linux and from OS X using WebStorm. But how can I do this with WebStorm? If I would create now a new project on OS X and clone the repository, the .gitignore and .idea will be cloned but node-modules directory will be missing.
So how can I develop a React app using WebStorm and different git repositories?
Thanks in advance
Andrej
Please sign in to leave a comment.
>If I would create now a new project on OS X and clone the repository, the .gitignore and .idea will be cloned but node-modules directory will be missing.
Cloning the repo on Mac is a right way to go.
Why do you need node_modules to be shared? They aren't normally pushed to the repository because of the overall folder size and luck of compatibility between OSs (node_modules installed on Linux won't likely work when being copied on Mac, some stuff there is OS-specific). And you can easily install modules locally after cloning the repo by running `npm i` in project root folder
Hi Elena,
thanks for reply. I don't want to clone node_modules. The point is, that the default project on WebStorm with React App contains the following files in the repository:
git log --name-status
commit 6d03e8cdf7d279f893b167122c58f7c284288459
...
Initial commit from Create React App
A .gitignore
A .idea/misc.xml << Is it Ok to have the same .idea directory in the repository?
A .idea/modules.xml << Is it Ok to have the same .idea directory in the repository?
A .idea/testreactapp.iml << Is it Ok to have the same .idea directory in the repository?
A .idea/workspace.xml << Is it Ok to have the same .idea directory in the repository?
A README.md
A package-lock.json
A package.json
...
A src/serviceWorker.js
The initial git repository, created by WebStorm, contains .gitignore and .idea directory. So If I would clone this repository to OS X, the same .idea directory will be shared between OS X and Linux. Is it Ok for WebStorm to share this directory between OS x and Linux? Do you support sharing of .idea?
Regards,
Andrej
Sure, .idea folder has to be version controlled if you like to share your project preferences between different OSs or with your co-workers. Please see https://intellij-support.jetbrains.com/hc/en-us/articles/206544839-How-to-manage-projects-under-Version-Control-Systems for details
Thanks a lot! This answered my question.