2

I've been trying for about a full day now to do a simple merge between a feature and develop.

Basically all I want is to be able to manually merge all the conflicts of feature into develop, so that I can get the new feature without destroying develop.

Here are the things I've tried so far

git checkout develop; git merge feature
git checkout feature; git merge -s ours develop
git checkout feature; git merge -s recursive -X ours develop
git checkout develop; git merge -s recursive -X theirs feature
git checkout develop; git merge -s recursive -X theirs feature
git checkout feature; git merge -s resolve develop

In all these cases either branch almost completely overrides the other. I am not given the chance to manually merge conflicts inside files.

git checkout feature; git rebase develop

mergetool is called for some files, but differences in one file are not recognized. It should be noted that this file was previously merged into develop a while ago. Files which were deleted in develop are still present in feature but with an 'orig' extension. This is the closest I've come so far to syncing both branches, but at the price of not being able to easily where the feature branches off anymore.

git checkout develop; git rebase feature

gives a bunch of options to delete or keep files and then results in error: file not found Continue merging other unresolved paths (y/n) ? y

I havent tried cherrypicking or orphaning trees yet. Perhaps the solution lies there?

Is it possible that I deleted some files and recreated them and thats why git is not even trying to combine branches?

Do I need to do manual merge every time I add a new feature? It seems difficult to do Git - how to force merge conflict and manual merge on selected file

I know I messed up somewhere, but I cant figure out where or what I'm doing wrong. I could just manually edit all the files that are not changed, but that would defeat the purpose of using git.

Where did I go wrong? How do I resolve this situation (without manually editing files)? And what should I do differently next time?

P.S. To whoever is new to git and experiencing similar troubles in learning how to use transformative features like merge and rebase git reflog feature-name and git reset --hard feature-name@{n} are invaluable commands. (always use --hard with supreme caution as it discards local changes)

EDIT: While I still dont know why this happened VonC offered a good stop-gap solution.

For anyone who's wondering the way you checkout from a local branch to a new local folder look at this post: https://stackoverflow.com/a/16493707/6419701

The way I conducted a merge is with the excellent meld tool for ubuntu using the syntax: meld folder1 folder2

Community
  • 1
  • 1
yosefrow
  • 2,128
  • 20
  • 29
  • Here are 2 other really useful commands I've been using while experimenting: git rebase --abort and git merge --abort – yosefrow Jun 06 '16 at 08:18

1 Answers1

1

In your current situation, I would:

  • checkout feature branch in a new path on the disk,
  • merge the two branches (develop and feature) with a diff tool (kdiff3 or other) outside git (ie, no git merge, just some old-fashion folder comparison/merge), and cleanup the .orig files,
  • record the merge from develop to feature with a git merge --ours develop.

Then, just for testing, I would make a concurrent modification on the same file in the two branches and see if a git merge develop does work and bring the conflict resolution step of a traditional git merge.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • While this is a good last resort solution, manually merging the files one at a time is what im trying to avoid. I'd like to be able to use git in the future and not have to manually change everything. I'm just trying to figure out why nothing works. My theory right now is that the file that wasnt included in the rebase, wasnt because there were no modifications made to it after it was branched to feature. Since rebase replays modifications over a base. – yosefrow Jun 06 '16 at 07:38
  • @yosefh don't waste anymore time: manual merge + merge record equals: you start from fresh. – VonC Jun 06 '16 at 07:40
  • VonC, I really appreciate your efforts to help me. But I'm trying to understand what I did wrong so I can avoid it in the future, and trying to fix it if possible. You are absolutely right though that to get results the practical solution is just to do a manual merge one file at a time. – yosefrow Jun 06 '16 at 07:43
  • @yosefh my goal is for you to start from a clean state, and *then* try a new merge to see if those issues persist. (instead of trying to make sense of the current situation) – VonC Jun 06 '16 at 07:44
  • So this was a good stop-gap measure. The subsequent merge test worked, and oddly when i conducted the merge test of merging feature back into develop it suddenly realized all the changes that I added in the manual merge came from feature and added them to the tree under feature's branch name. Is it possible I got to this situation because I didnt merge with develop often enough? – yosefrow Jun 07 '16 at 14:08
  • Yes, it is possible: merging often and regularly is the best practice. – VonC Jun 07 '16 at 15:07