GIT:在您的根文件夹中使用CRA应用程序,如何正确推送git? [英] GIT: with CRA app in your rootfolder, how can I push to git correctly?

查看:89
本文介绍了GIT:在您的根文件夹中使用CRA应用程序,如何正确推送git?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对git很陌生.这可能是一个愚蠢的问题,但是我真的不知道如何解决这个问题..我一直在寻找答案,但是我无法...

I am quite new to git. it might be a stupid question but I really don't know how to solve this problem.. I have been trying to find the answer but I couldn't...

我试图使用React.js和Node.js创建我的项目.我创建了sever.js和从"npx create-react-app客户端"创建的客户端文件夹. 当我第一次推送到git时,我收到了此错误消息.

I was trying to create my project using React.js and Node.js. I created my sever.js and client folder that is created from 'npx create-react-app client'. when I first pushed to git, I had this error message.

 ! [rejected]        master -> master (fetch first)
error: failed to push some refs
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

当我强行按下它时,它就通过了,我发现我的客户文件夹根本没有被推送到git,在回购中它只是空的.另外,我注意到客户端文件夹中有.git文件夹.(不知道cra app附带了.git文件)

when I force-pushed it, it just went through and I found my client folder is not pushed to git at all, it is just empty in the repo. also, I noticed there was .git folder in client folder.(did not know cra app comes with .git file)

在客户端文件夹中,我在命令行中键入(我用google搜索,发现此命令将撤消.git init)

in client folder, I typed on command line (I googled and i found this command will undo .git init)

rm -rf .git

在此之后,我没有收到错误消息,但仍然无法将客户端文件夹推送到git,该文件夹在回购单中仍然为空.

after this, I dont get the error message but still I cannot push client folder to git, the folder is still empty in the repo.

此外,存储库中客户端文件夹的图像与其他图像不同.文件夹中有一个箭头,另一个文件夹中没有错误. 在此处输入图片描述

Also, the image of client folder in the repo is different then others. there is an arrow in the folder, the other folder does not have an arror in it. enter image description here

客户端文件夹是cra应用,而src文件夹具有服务器端代码.

client folder is cra app and src folder has server side codes.

我如何正确地将代码推送到git?

how can I push my code to git correctly??

推荐答案

您需要先删除 gitlink (特殊条目,记录

You need first to remove the gitlink (special entry recording the tree SHA1 of the nested git repository for the client folder)

git rm --cached client # no trailing /: not client/, just client

然后就可以了(因为您已经删除了client/.git子文件夹),添加了客户端(git add client),然后提交并推送.

Then you can (since you have removed the client/.git subfolder), add client (git add client), commit and push.

这篇关于GIT:在您的根文件夹中使用CRA应用程序,如何正确推送git?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆