git merge squash - conflict resolution when all I want is the changes from the branch I squashed from

后端 未结 2 1304
野性不改
野性不改 2021-01-22 21:17

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/D         


        
相关标签:
2条回答
  • 2021-01-22 21:59

    You have to follow up the git merge --squash with a git commit, so there is a possible fault in your workflow.

    You can use git merge -s theirs to specify that you always want the other, master branch in this case, to win all merge conflicts. (Though I am surprised you get merge conflicts if you do no separate work on the github branch)

    0 讨论(0)
  • 2021-01-22 22:12

    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

    0 讨论(0)
提交回复
热议问题