B.W
B.W

Reputation: 21

TortoiseGIT different file merge

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

Upvotes: 0

Views: 701

Answers (1)

LeGEC
LeGEC

Reputation: 52236

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.

Upvotes: 2

Related Questions