duancu4731 2017-01-11 23:16
浏览 406
已采纳

你的分支和'origin / yourbranch'有分歧保存本地文件

I have this diverge branch issue. In many of these cases you want to throw away your local changes. But in this case I'm really happy with my local files.

So basically what I want to do is to replace everything with my current local files. I would even like to replace my master branch. How do i do this?

Here is the error message:

Your branch and 'origin/yourbranch' have diverged,
and have 4 and 7 different commits each, respectively.
  • 写回答

1条回答 默认 最新

  • drhe80011 2017-01-12 01:59
    关注

    There are two ways for you to abandon the old changes:

    1. Diverged local branch with repo branch. As you have diverged local yourbranch and origin/yourbranch, you can force to keep origin/yourbranch same as the local yourbranch by git push -f origin yourbranch.
    2. If you really want to abandon every changes in yourbranch, you can make an orphan branch (no parent commit id) from it by git checkout --orphan yourbranch1.

    The ways can also apply to master, you just need to delete master branch (git branch -D master) and then rename a branch to master (git branch -m oldname master).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿