0

我在一个网站上工作,我正在使用 React-create-app 和它的 webpack 配置。我一直在推动 Github 回购,没有任何问题。几天前,我把我正在制作的网站变成了一个 Github Pages 网站(即 mygithubname.github.io)。

将此 repo 转换为 Github Pages 站点后,我的项目 repo 的结构发生了变化。看起来它为了将代码放到网上而最小化了代码。一旦我推送了这个 repo 并让它成为一个 live 的 Github Pages 站点,我突然就不能再推送到 repo 了。

如果我推送到 repo,我会收到一个错误:

! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/Nicknyr/New_Portfolio.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

我在网上做了一些搜索,并试图git pull origin master纠正这个问题。如果我尝试删除 75% 的项目,并且我的大部分组件都会丢失。这是结果git pull origin master

git pull origin master
From https://github.com/Nicknyr/New_Portfolio
 * branch            master     -> FETCH_HEAD
Removing yarn.lock
CONFLICT (modify/delete): src/styles/_Projects.scss deleted in 5977716b3eb3a9424a9efdbf835a0a2ae9cf6f88 and modified in HEAD. Version HEAD of src/styles/_Projects.scss left in tree.
CONFLICT (modify/delete): src/styles/_Info.scss deleted in 5977716b3eb3a9424a9efdbf835a0a2ae9cf6f88 and modified in HEAD. Version HEAD of src/styles/_Info.scss left in tree.
Removing src/styles/_Header.scss
CONFLICT (modify/delete): src/styles/_Global.scss deleted in 5977716b3eb3a9424a9efdbf835a0a2ae9cf6f88 and modified in HEAD. Version HEAD of src/styles/_Global.scss left in tree.
Removing src/styles/_Footer.scss
Removing src/styles/_ContactForm.scss
Removing src/styles/_Contact.scss
Removing src/registerServiceWorker.js
Removing src/logo.svg
Removing src/index.js
Removing src/index.css
Removing src/images/tic-tac-toe-medium.png
Removing src/images/steem-medium.png
Removing src/images/resume-new.png
Removing src/images/resume-medium.png
Removing src/images/redo.png
Removing src/images/pomodoro-small.png
Removing src/images/placeholder.png
Removing src/images/nodes-no-color.jpg
Removing src/images/name-logo.png
Removing src/images/name-logo-small.png
Removing src/images/euro-small.png
Removing src/images/euro-large.png
Removing src/images/euro-250.png
Removing src/images/centered.png
Removing src/images/blue-nodes-opacity.jpg
Removing src/images/background-2462434_1920.jpg
CONFLICT (modify/delete): src/Projects.js deleted in 5977716b3eb3a9424a9efdbf835a0a2ae9cf6f88 and modified in HEAD. Version HEAD of src/Projects.js left in tree.
Removing src/NodeMailer.js
CONFLICT (modify/delete): src/Menu.js deleted in 5977716b3eb3a9424a9efdbf835a0a2ae9cf6f88 and modified in HEAD. Version HEAD of src/Menu.js left in tree.
Removing src/Info.js
CONFLICT (modify/delete): src/Header.js deleted in 5977716b3eb3a9424a9efdbf835a0a2ae9cf6f88 and modified in HEAD. Version HEAD of src/Header.js left in tree.
Removing src/Footer.js
Removing src/ContactForm.js
CONFLICT (modify/delete): src/Contact.js deleted in 5977716b3eb3a9424a9efdbf835a0a2ae9cf6f88 and modified in HEAD. Version HEAD of src/Contact.js left in tree.
Removing src/App.test.js
Removing src/App.scss
CONFLICT (modify/delete): src/App.js deleted in 5977716b3eb3a9424a9efdbf835a0a2ae9cf6f88 and modified in HEAD. Version HEAD of src/App.js left in tree.
CONFLICT (modify/delete): src/App.css deleted in 5977716b3eb3a9424a9efdbf835a0a2ae9cf6f88 and modified in HEAD. Version HEAD of src/App.css left in tree.
Removing public/index.html
CONFLICT (modify/delete): package.json deleted in 5977716b3eb3a9424a9efdbf835a0a2ae9cf6f88 and modified in HEAD. Version HEAD of package.json left in tree.
Removing README.md
Removing .gitignore
Automatic merge failed; fix conflicts and then commit the result.

它删除了我的大部分项目。我通过git reset --hard. 我找回了我的项目文件,但我仍然无法推送到 Github。

这是将我的网站变成 Github Pages 网站后我的仓库发生的情况。正如你所看到的,它删除了我的大部分项目,这似乎是我去时要恢复的内容git pull origin master

我该如何解决这个问题?我想让我的分支走上正轨,这样我就可以继续推进它而不会丢失所有这些文件。

4

1 回答 1

0

确保您已提交文件或目录

git add .

或文件/目录名称而不是“。”

git commit --all

git push origin master

此外,您需要确保您不在已经推送的代码后面。如果是这样,将引发此错误

于 2018-08-04T00:21:04.273 回答