| 234 | == I don't see any merge commit == |
| 235 | |
| 236 | ..you probably either forgot to add the `--no-ff` option when calling the merge (by default, but only if the merge is fast-forward, a normal single-parent commit is created), or somehow your .git/MERGE_HEAD passed away. |
| 237 | |
| 238 | This means you have your merge commit with lots of conflicts fixed that you want to re-apply. |
| 239 | One idea is to: |
| 240 | |
| 241 | * save your merge to a patch, say `MERGE.patch` |
| 242 | * reset to a pre-merge state and re-merge |
| 243 | * if you have conflicts, just git-add everything to make git think you solved them, then commit |
| 244 | * revert the (fake) commit and format a patch out of it, say `REVERT.patch` |
| 245 | * reset again to a pre-merge state and again re-merge |
| 246 | * re-git-add everything to mark conflicts solved (even though they aren't), but don't commit this time |
| 247 | * apply `REVERT.patch` then `MERGE.patch` in the index |
| 248 | * the two patches are applied, now you can git-commit. |
| 249 | |
| 250 | Let's say you applied a merge `M` of `feature_X` into `master`, but you see no merge commit in your history: |
| 251 | |
| 252 | {{{ |
| 253 | o-------A--------------M master |
| 254 | \ |
| 255 | C----------D feature_X |
| 256 | }}} |
| 257 | |
| 258 | {{{ |
| 259 | #!sh |
| 260 | # Patch your merge commit: |
| 261 | $ git branch |
| 262 | * master |
| 263 | feature_X |
| 264 | $ git format-patch HEAD~ |
| 265 | MERGE.patch |
| 266 | |
| 267 | # Re-merge |
| 268 | $ git reset --hard A |
| 269 | $ git merge --no-ff feature_X |
| 270 | ... |
| 271 | Automatic merge failed; fix conflicts and then commit the result. |
| 272 | |
| 273 | # Mark conflicts as solved, without applying changes |
| 274 | $ git add folder1/ folder2/ ... |
| 275 | $ git commit |
| 276 | # let's call it M' |
| 277 | |
| 278 | # Revert your fake merge |
| 279 | $ git revert -m 1 M' |
| 280 | # let's call this commit rM' |
| 281 | |
| 282 | # Patch the reversion |
| 283 | $ git format-patch HEAD~ |
| 284 | REVERT.patch |
| 285 | }}} |
| 286 | |
| 287 | Graphically, this is the current situation: |
| 288 | |
| 289 | {{{ |
| 290 | o-------A--------------M'----------rM' master |
| 291 | \ / |
| 292 | C----------D feature_X |
| 293 | }}} |
| 294 | |
| 295 | Now we roll-back to a pre-merge state again, then we merge, revert, and apply our initial patch: `(M'+rM'+M) = (M'-M'+M) = M` |
| 296 | |
| 297 | {{{ |
| 298 | #!sh |
| 299 | # Re-merge |
| 300 | $ git reset --hard A |
| 301 | $ git merge --no-ff feature_X |
| 302 | ... |
| 303 | Automatic merge failed; fix conflicts and then commit the result. |
| 304 | |
| 305 | # Mark conflicts as solved, without applying changes, but don't commit now |
| 306 | $ git add folder1/ folder2/ ... |
| 307 | # ... now we are @ M', without explicit commit |
| 308 | |
| 309 | # Apply rM' and M (without commiting) |
| 310 | $ git apply --index REVERT.patch |
| 311 | $ git apply --index MERGE.patch |
| 312 | }}} |
| 313 | |
| 314 | Finally, we have our original merge, with true conflicts solution, but as a merge commit: |
| 315 | |
| 316 | {{{ |
| 317 | o-------A--------------M master |
| 318 | \ / |
| 319 | C----------D feature_X |
| 320 | }}} |
| 321 | |
| 322 | |