2

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:

    enter image description here

Community
  • 1
  • 1
Mr_and_Mrs_D
  • 32,208
  • 39
  • 178
  • 361
  • _I would like to know what Use Local Version and Use Remote Version mean in this pic - msysgit_: this is still a mystery – Mr_and_Mrs_D Jul 18 '13 at 20:28

2 Answers2

3

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

Community
  • 1
  • 1
Mr_and_Mrs_D
  • 32,208
  • 39
  • 178
  • 361
1

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)

Klas Mellbourn
  • 42,571
  • 24
  • 140
  • 158
  • To commit I have first to resolve the conflicts - but those merge conflicts is what I am after (and also wandering at) – Mr_and_Mrs_D May 07 '13 at 18:14
  • If you have not committed anything but merges to the github branch, I would reset the current merge and start it over again. `git reset --merge` works nicely. – Klas Mellbourn May 07 '13 at 18:16
  • I does not make a difference - still the conflicts appear – Mr_and_Mrs_D May 07 '13 at 18:18
  • 1
    If you are sure about wanting all the changes from master, then `git merge -s theirs` should resolve all conflicts. Have you tried that? – Klas Mellbourn May 07 '13 at 18:20
  • "I am surprised you get merge conflicts if you do no separate work on the github branch" - I was too - check the links in my answer – Mr_and_Mrs_D Jul 18 '13 at 20:27
  • For those interested, here's a link to the git docs for the `merge` command and the different merge strategies you can specify with the `-s` merge strategy option used in this answer. https://git-scm.com/docs/git-merge/#_merge_strategies – munsellj Apr 20 '16 at 19:10