error: failed to push some refs to 'URL' Git Bash Error Don't Solved

error: failed to push some refs to 'URL' Git Bash Error Don't Solved

我尝试了所有重复的问题,但其中 none 成功了。请问你能分别给我写出正确的语法吗?

我分别试过:

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.

从消息来看,远程中似乎有您在本地丢失的提交。尝试比较:

git fetch origin
git diff origin/master

那应该告诉你你错过了什么。如果您当前的分支可以同步,您应该可以这样做:

git pull origin master

那么,除非存在合并冲突,否则您的推送应该会起作用。您可能想创建另一个分支只是为了测试它,让您的本地分支保持当前状态,并避免 git 在拉动不顺利时摆弄。