0

Problem Statement: What is the way to merge changes from a revision from file A (10_34_0_0.XML) to file B (10_35_0_0.XML) in TortoiseGIT in 2 different branches?

Background of the problem: We recently did a SVN to GIT migration, the later realized that the team is heavily using the TortoiseSVN file merge functionality WITH selecting changes from a revision.

We were not able to find similar functionality in TortoiseGIT. This is not the same as GIT Cherry Picking. In Cherry picking you can select commit/set of commits to merge from the same file in 2 different branches.

Example: TortoiseSVN Process.

Step 1: Select File and click merge. enter image description here

Step 2: Select merge option enter image description here

Step 3: Select the file and the branch you want to merge from enter image description here

Step 4: Select the revision that you want the changes from enter image description here enter image description here

Step 5: Continue to merge enter image description here

Step 6: Merge results enter image description here

bahrep
  • 29,961
  • 12
  • 103
  • 150
B.W
  • 21
  • 5

1 Answers1

2

As suggested in this other question, one way to do this from the command line is :

  • create a patch file describing the diff on the first file (using git diff)
  • apply it on the second file, using the standard patch utility

In more details :

git diff revisionA^ revision -- 10_34_0_0.XML > patch_file
cat patch_file | patch 10_35_0_0.XML

# you can write the above as a one liner with no tmp file :
git diff revisionA^ revision -- 10_34_0_0.XML | patch 10_35_0_0.XML

On Windows, you can run this from git-bash (the installation comes with the patch utility).


I wouldn't know how to do this through TortoiseGIT's GUI however.

LeGEC
  • 46,477
  • 5
  • 57
  • 104
  • This was very helpful, below is the exact command that was used. We were able to create the patch using the TortoiseGIT GUI, then applied it using git bash. **patch --binary 10_35_0_0.XML patch_file.patch** – B.W Jul 23 '20 at 20:56