[英]Merge folder from one branch into another with git
I'm working with two branches in a git repository. 我正在使用git存储库中的两个分支。
They are rc
and dev
. 它们是rc
和dev
。
I have a folder in dev
src/
that I need to merge into rc
. 我在dev
src/
中有一个文件夹,我需要将其合并到rc
。
I've tried to use git cherry-pick --strategy=recurisve --strategy-option=theirs <commit>
method by first creating a shell script to add a new line to all the files in the directory to trigger a change with git. 我尝试使用git cherry-pick --strategy=recurisve --strategy-option=theirs <commit>
方法,方法是先创建一个shell脚本,向目录中的所有文件添加新行,以使用git触发更改。
The script was as follows: 脚本如下:
#/bin/sh
SEARCH_FOLDER="src/*"
for f in $(find $SEARCH_FOLDER);
do
echo "" >> $f;
done;
What I did not realize is that git cherry-pick
is only going to take the recognized changes vis-a-vis the aforementioned newlines. 我没有意识到的是git cherry-pick
只会采取相对于上述换行符的公认更改。
Aside from just copying the folder over into a branch of rc
and then creating a commit and merging, what are my options to push my changes that I've been working on in dev
for two weeks into the rc
branch. 除了将文件夹复制到rc
分支中,然后创建提交并合并之外,还有什么选择可以将我在dev
进行了两周的更改推送到rc
分支中。
I understand that the way I have been developing and using git is probably inappropriate and not intended use. 我知道我一直在开发和使用git的方式可能是不合适的,并非有意使用。
Ideally, I'd like to create a patch file using the diff on the two branches subfolders src/
and apply it. 理想情况下,我想使用两个分支子文件夹src/
上的diff创建一个补丁文件并应用它。 Though, I'm not sure how to execute this approach. 不过,我不确定如何执行此方法。
You should be able to grab the whole src
folder from rc
into dev
like this: 您应该可以像这样从rc
抓取整个src
文件夹到dev
:
While on your rc
branch: 在rc
分支上时:
git checkout dev -- src/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.