git - 强制推送到不同的分支时,Git 不会将新文件推送到远程
问题描述
我有两个分支:no-users
和old-state
. 在本地,我在no-users
. 我退出old-state
并修复了合并冲突。现在我想推送old-state
覆盖该分支上的所有内容并传输新文件,但强制推送( )以某种方式不推送在分支git push -f origin old-state
中创建的文件。正在写强制推送已成功运行,但远程文件不存在。no-users
Git
解决方案
当你做了
git push -f origin old-state
你推送到提交指向的远程old-state
,自从你合并old-state
到,它没有改变no-users
,而不是相反。这就是为什么强制在这里没有改变任何事情的原因。您的推送没有被拒绝,它只是发送了一个遥控器已经拥有的 ref。
此时只有no-users
树的两个部分,所以你最好的方法是
git checkout old-state
# if you're not sure whether you're up-to-date on this branch,
# you might as well do it now before the merge
git pull
git merge no-users
并且您将能够不费力地推动:
git push origin old-state
推荐阅读
- android - 在 4G 数据连接处于活动状态的情况下通过 wifi 发送和接收多播数据包
- rational-team-concert - 来自现有基线/截断历史的新 RTC 流
- python - 使用 pandas 的 txt 中的 CSV 文件
- r - ggplot2:防止 geom_bar 按字母顺序排列,并且 y 刻度不显示中断
- r - 将两个数据帧除以R中的公共行
- javascript - 使用外部 API 进行身份验证
- mysql - 想比较两个Mysql表中的文本
- angular - Angular 4 Jasmine 测试监视属性以将不同的值返回给不同的测试
- javascript - 从内存中存储和检索数据是否比使用数据属性和 jQuery 从 DOM 中存储和检索数据更快?
- python - 散景极地投影