0

I want to create a branch in GIT with the file differences from 2 other git branches. I do not want whole repo copy but only the changed files keeping rest of the folder structure as is. How can I achieve this?

For example:

Branch 1: testbranch1

deployment/src/main/apiproxy/myorg/folder1/file1.txt
deployment/src/main/apiproxy/myorg/folder1/file2.txt
deployment/src/main/apiproxy/myorg/folder2/file1.txt
deployment/src/main/apiproxy/myorg/folder2/file2.txt

Branch 2: testbranch2

deployment/src/main/apiproxy/myorg/folder1/file1.txt -> File Changed
deployment/src/main/apiproxy/myorg/folder1/file2.txt
deployment/src/main/apiproxy/myorg/folder2/file1.txt
deployment/src/main/apiproxy/myorg/folder2/file2.txt -> File Changed

New branch should have:

deployment/src/main/apiproxy/myorg/folder1/file1.txt
deployment/src/main/apiproxy/myorg/folder2/file2.txt
max630
  • 7,979
  • 3
  • 27
  • 52
Tarun
  • 25
  • 1
  • 6
  • 1
    I'm having trouble understanding what you mean. Could you [edit] your question and provide an example, possibly as a [mcve]? – Chris Sep 20 '17 at 15:13
  • May be `git rebase --onto` ?! https://stackoverflow.com/questions/29315281/merge-diff-between-two-branches-to-third-branch – SriniV Sep 20 '17 at 15:14
  • Example added to the question. – Tarun Sep 20 '17 at 15:44

1 Answers1

0

Instead of creating a new branch, You can just create a patch for the changes.

git format-patch testbranch2 --stdout > mypatch.patch

Later if you need to apply your patch, do the following.

git apply mypatch.patch
Md. Al-Amin
  • 1,401
  • 1
  • 13
  • 25