为什么即使我重置了git,也不能进行git推送?

vq8itlhq  于 2022-11-20  发布在  Git
关注(0)|答案(1)|浏览(141)

我正在尝试推送最新的本地更改,但出现错误。

! [rejected]        dev -> dev (non-fast-forward)
error: failed to push some refs to 'https://******************.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and 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 pull

始终返回Already up to date.

  • git reset --hard

返回HEAD is now at ****** COMMITNAME。正确。

  • git fetchgit merge

呼叫git merge时传回fatal: No current branch.
我想做的
我下面要做的只是。

git add .
git commit -m ""
git push origin dev

现在,git push origin dev就是问题所在。
我不知道该怎么办。有人知道解决办法吗?

thigvfpy

thigvfpy1#

为了确保你的本地dev分支不在远程dev分支之前,在推送之前拉并合并更改。这可以通过rebase来完成。

git pull origin dev --rebase
git push -f origin dev

相关问题