git合并压缩 - 当我想要的是来自我压扁的分支的变化时解决冲突 [英] git merge squash - conflict resolution when all I want is the changes from the branch I squashed from

查看:305
本文介绍了git合并压缩 - 当我想要的是来自我压扁的分支的变化时解决冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当master分支达到某种可接受的状态时(我们已经完成了这个操作),我有了一个github分支。为此,我做了:
$ b $ pre $ MrD @ MRSD / c / Dropbox / eclipse_workspaces / android / AndroidMonitoring(master)
$ git checkout github
转换到分支'github'
MRD / c / Dropbox / eclipse_workspaces / android / AndroidMonitoring(github)
$ git merge --squash master
Auto -merging src / gr / uoa / di / monitoring / android / services / Monitor.java
CONFLICT(添加/添加):合并src / gr / uoa / di / monitoring / android / services / $ b $中的冲突b Monitor.java
// ...
自动合并失败;修复冲突,然后提交结果。

我只想让工作目录完全在相同的位置状态和主HEAD一样。


  • 是我这样做的错误方式(反复合并--squashing到github分支中)。
  • 是否有一种简单的防白痴方法来实现这一点(不经过每次冲突)。作为奖励,我希望了解使用本地版本使用远程版本在此图片中的含义 - msysgit:



那么经过大量的谷歌搜索后,我发现我的策略是错误的。 git merge --squash 不会做我想要的 - 即将我的主分支镜像到我的github分支,而不保留master中的提交历史记录(纯粹的合并会执行但我不想在github中拥有任何master的历史记录)。
对于其中一个,它不会删除已删除的文件 - 对于一个很好的解释,请参见这里

可能还有其他一些缺陷 - 包括永久性的冲突解决方案
https://stackoverflow.com/a/4481621/281545\">这里

  $ git checkout master @ { 0} 
$ git reset --soft github
$ git commit
$ git branch temp
$ git checkout temp
$ git branch -M github
$ git push -u -v origin github:master



t并且它确实符合我的要求


I have github branch which I push to github when the master branch reaches some acceptable state (have done this once). To this end I did :

MrD@MRSD /c/Dropbox/eclipse_workspaces/android/AndroidMonitoring (master)
$ git checkout github
Switched to branch 'github'
MrD@MRSD /c/Dropbox/eclipse_workspaces/android/AndroidMonitoring (github)
$ git merge --squash master
Auto-merging src/gr/uoa/di/monitoring/android/services/Monitor.java
CONFLICT (add/add): Merge conflict in src/gr/uoa/di/monitoring/android/services/
Monitor.java
//...
Automatic merge failed; fix conflicts and then commit the result.

What I want is to just have the working directory exactly in the same state as in master HEAD.

  • Is my way of doing this wrong (repeatedly merge --squashing into the github branch).
  • Is there an easy, idiot-proof way to achieve this (without going through each conflict).
  • As a bonus I would like to know what Use Local Version and Use Remote Version mean in this pic - msysgit:

解决方案

Well after a lot of googling it turns out that my strategy was wrong. git merge --squash does not do what I want - namely mirroring my master branch to my github branch, without keeping the history of the commits in master (a plain merge would do but I did not want to have any of the master's history in github).
For one it does not delete deleted files - for a nice explanation see here
There are probably other pitfalls - including the eternal conflict resolution that can't be avoided

Anyway I think I found the correct way - the one detailed here

$ git checkout master@{0}
$ git reset --soft github
$ git commit
$ git branch temp
$ git checkout temp
$ git branch -M github
$ git push -u -v  origin github:master

tried it and it does work as I wanted

这篇关于git合并压缩 - 当我想要的是来自我压扁的分支的变化时解决冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆