我对 git 很陌生。这可能是一个愚蠢的问题,但我真的不知道如何解决这个问题..我一直在努力寻找答案,但我找不到......
我试图使用 React.js 和 Node.js 创建我的项目。我创建了从“npx create-react-app client”创建的 sever.js 和 client 文件夹。
当我第一次推送到 git 时,我收到了此错误消息。
! [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 应用程序附带 .git 文件)
在客户端文件夹中,我在命令行上输入(我用谷歌搜索,发现此命令将撤消 .git init)
rm -rf .git
之后,我没有收到错误消息,但仍然无法将客户端文件夹推送到 git,该文件夹在存储库中仍然为空。
此外,存储库中客户端文件夹的图像与其他文件夹不同。该文件夹中有一个箭头,另一个文件夹中没有箭头。在此输入图像描述 https://i.stack.imgur.com/jZ62H.jpg
client 文件夹是 cra app,src 文件夹有服务器端代码。
我怎样才能正确地将我的代码推送到git?
您需要先删除gitlink https://stackoverflow.com/a/16581096/6309 (特别条目 https://stackoverflow.com/a/19354410/6309记录树的 SHA1嵌套的 git 存储库 https://stackoverflow.com/a/62057615/6309为了client
文件夹)
git rm --cached client # no trailing /: not client/, just client
然后你就可以(因为你已经删除了client/.git
子文件夹),添加客户端(git add client
),提交并推送。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)