git - 错误:未能将一些引用推送到“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.
解决方案
从消息中听起来,您在本地缺少远程提交。尝试比较:
git fetch origin
git diff origin/master
这应该告诉你你缺少什么。如果您当前的分支可以同步,您应该能够:
git pull origin master
然后,除非存在合并冲突,否则您的推送应该可以工作。您可能希望创建另一个分支只是为了测试它以使您的本地分支保持当前状态,并在拉取不顺利时避免 git 摆弄。
推荐阅读
- ruby-on-rails - 如何在 ActiveAdmin 中使用 ActiveStorage `has_many_attached` 编辑多个附加图像
- typescript - 在 vscode 扩展中更新 editor.selections
- reactjs - React JSX 中的多个 if else
- android - kotlin 不确定如何处理插入方法的返回类型
- c# - 当项目名称与命名空间不同时,@localizer mvc 找不到资源
- ruby-on-rails - 带有 Apartment gem 和 Stimulus Reflex 的 ActionCable 错误
- node.js - 竹子引起恐慌:构建角度应用程序时由于终端初始化失败而中止
- vmware - 打开 vmx 文件在 vmware 工作站中不起作用
- javascript - 为什么 TypeScript 不支持导出 @deco?
- amazon-dynamodb - 如何将 DynamoDB IAM 角色添加到 Terraform 中的 EKS 工作节点?