Git 推送错误,远程仓库的负责人落后于本地

Git push error, head of distant repo is behind local

我的项目在 gitlab 上有一个回购协议。我首先在 windows 上提交并推送这个项目。在 ubuntu 上创建 VM 并将我的项目文件夹复制粘贴到它上面。我在 ubuntu 上继续我的项目并且我确实提交了(没有推送)。我不再使用我的 windows 项目。现在,当我想推送项目 (ubuntu) 时,我遇到了错误。我想我有冲突和合并问题。 我如何 push 我的项目在 repo 上。我尝试 pullfetch 但什么也没有。

错误是:

! [rejected]        master -> master (non-fast-forward)
impossible to push references to 'repo'
tip: The updates were rejected because the head of the current branch is behind its remote peer. Integrate remote changes (eg 'git pull ...') before pushing again.

在那之后,当我执行 git pull origin master 时,我与许多文件发生了很多冲突。

你能帮帮我吗?

git 拉取 时,git 将合并 冲突文件 ,你需要解决冲突和 commit 再次推送 (git push origin master) update code on git.

有关更多信息,请查看此 link: rejected master -> master (non-fast-forward)

您应该执行 git pull 并解决冲突文件。打开每一个,修复它,然后 git add 它。你会发现这样的冲突行:

对所有冲突文件执行此操作后,测试您的代码并运行 git commit 合并。之后你就可以推送了。

git 不允许您 pushpullfetch,因为您复制粘贴了整个目录。这也复制了 git 在 git init 上创建的 .git 文件夹。删除 .git 文件夹,然后使用 git init.

重新初始化 git 存储库

这将根据新路径创建一个新的 .git 指向。