简体   繁体   English

新的Git分支与另外2个差异

[英]New Git branch with diff of 2 others

I want to create a branch in GIT with the file differences from 2 other git branches. 我想用其他2个git分支的文件差异在GIT中创建一个分支。 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 分支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 分支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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM