首页 > 解决方案 > 错误:未能将一些引用推送到“URL”Git Bash 错误未解决

问题描述

我尝试了所有重复的问题,但没有一个有效。请问你能分别为我写正确的语法吗?

我分别尝试过:

git add .

git commit -m "comment"

git remote add origin https://github.com/dgknca/DogukanCavus_H5180005-MuhammetFurkanAydogdu_H5180045

git push -u origin master

push -f有效,但我不想使用它。因为它正在删除所有以前的提交。

这是我的错误:

sezginc@dgknca MINGW64 ~/desktop/DogukanCavus_H5180005-MuhammetFurkanAydogdu_H5180045-master (master)
$ git push -u origin master
To https://github.com/dgknca/DogukanCavus_H5180005-MuhammetFurkanAydogdu_H5180045
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/dgknca/DogukanCavus_H5180005-MuhammetFurkanAydogdu_H5180045'
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.

标签: gitgithubgit-bash

解决方案


从消息中听起来,您在本地缺少远程提交。尝试比较:

git fetch origin
git diff origin/master

这应该告诉你你缺少什么。如果您当前的分支可以同步,您应该能够:

git pull origin master

然后,除非存在合并冲突,否则您的推送应该可以工作。您可能希望创建另一个分支只是为了测试它以使您的本地分支保持当前状态,并在拉取不顺利时避免 git 摆弄。


推荐阅读