-2

I have 2 branches on a project, both with plenty of changes since branching. Now I need to merge changes from one to other (and possibly into new branch, but it doesn't really matter - whatever is easier). I would like to do the merge manually in some GUI tool (I am on Ubuntu 19.10). Many tools I tried shows differences nicely (e.g. GitKraken, SmartGit). I would like to pick which change to use (either left or right - see screenshot)enter image description here

And all this preferably using shortcuts. So something like this:

  1. selecting 2 branches to compare
  2. going to first difference and selecting which version I like
  3. repeat until the end of the list
  4. saving all the files and then committing to new branch.

I know it is possible to do it manually using copy&paste method and text (code) editor, but that would be to much hassle.

Juraj.Lorinc
  • 503
  • 6
  • 26
  • 2
    What's the question? All the tools that give you the sort of side by side comparison you are showing also let you pick which difference to use (left or right). Just do it. – matt Jun 23 '20 at 18:43
  • Can you describe what holds you from doing automatic merge? – snipsnipsnip Jun 24 '20 at 05:50
  • @matt non of them does (at least non I know) when you are just comparing branches and not doing actual merge. – Juraj.Lorinc Jun 24 '20 at 10:47
  • @snipsnipsnip I would preffer to do it in small steps and not doing full merge at once. – Juraj.Lorinc Jun 24 '20 at 10:49
  • Does this answer your question? [Git - how to force merge conflict and manual merge on selected file](https://stackoverflow.com/questions/5074452/git-how-to-force-merge-conflict-and-manual-merge-on-selected-file) – snipsnipsnip Jun 24 '20 at 11:24
  • Well, Stack Overflow is not the venue to discuss tools. Try Super User. But I’m on a Mac and I have at least three graphical diff tools that display file or folder differences and let me reconcile them manually in just the way you seem to describe. This is entirely independent of git and merging. So I venture to guess that you’re just wrong about what’s available on your platform. – matt Jun 24 '20 at 13:41

2 Answers2

0

Have you tried running git merge ?

Say you want to merge branches A and B, possibly in a new branch named new

# from branch A : create branch 'new'
git checkout A
git checkout -b new

# run git merge : add the --no-commit option to be sure to manually review before committing
git merge B

How many merge conflicts are listed at this point ?

If the number of conflicting files is small, fix these, review the global changes, then commit the result.


Otherwise, running a diff tool is as simple as :

# from branch 'new' as above :
# choose the tool you wish to use
git difftool -d --tool=meld B new

You can review file by file the changes, choose the chunks you want, and save.

LeGEC
  • 46,477
  • 5
  • 57
  • 104
-1

Recommended will be manual because you need to take decision in case of any kind of code conflicts. You can simple select the side of code you would like to accept.

Shradha
  • 59
  • 3