无法推送到Github非快进错误

时间:2018-08-03 23:54:45

标签: git github github-pages git-pull fast-forward

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

将此仓库转换为Github Pages网站后,我项目的仓库的结构发生了变化。看起来它是为了将代码放到网上而将代码最小化了。一旦我推送了这个仓库,并使其成为一个活跃的Github Pages站点,我突然无法再推送到这个仓库。

如果我推送到仓库,则会出现错误:

! [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。

Here is what happened to my repo 后,将我的网站设置为Github Pages网站。如您所见,它删除了我的大部分项目,而这似乎是我git pull origin master回到时所恢复的状态。

如何解决这个问题?我想让分支步入正轨,以便我可以继续推动它,而不会丢失所有这些文件。

1 个答案:

答案 0 :(得分:0)

确保您已提交文件或目录

git add .

或者用文件/目录名代替“。”

git commit --all

git push origin master

此外,您还需要确保您没有落后于已经推送的代码。如果是这样,则会引发此错误