Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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?

>Solution :

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading