-1

Merging in TortoiseGit will automatically merge a file to the latest code if there are no conflicts.

However, I'd like to choose some blocks to merge only (the files don't conflict). Is it possible to show a file list of those have differences to choose which blocks to use before merging in and commit?

1
  • 2
    I think the thing you may be missing is that it's Commits that are merged not Files. SVN-like source control is file-state based, but git doesn't work that way. its one of the biggest struggles for new git developers coming from a different VC system. So what you need is a commit that contains only the changes you want. then you merge that, but it will be the whole commit, not just selected items from it. Commented May 5, 2023 at 18:19

2 Answers 2

1

Open the logdialog, select the revision on the branch you want to merge. Open the contextmenu and select "Compare to working tree". Then you'll get a diff of all files. When you now doubleclick on a file, TortoiseGitMerge is opened and you and select the lines that you want to have.

Please note, that this is not a real merge. You are just changing the files in the working tree.

1
  • this is true if you are the only developer on the branch (since its local-only data), so you are comparing to what the file was prior to your changes. it won't see changes that have happened on the branch upstream, which is where conflicts come from. you can't conflict with yourself in your local unless you do some really odd stuff with squashes, etc. Commented May 5, 2023 at 18:38
0

I needed to merge that way because of the need to merge features of a derived project back to base project and there are 2 types of file:

  • supposed to be the same (regular merge)
  • supposed to be different (pick some functions only)

I found another way is to use this Browse References from TortoiseGit context menu and I can diff 2 branches (of base project vs of derived project). This is a way to select needed code blocks but those files should be the same are not automatically merged.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .