简体   繁体   English

使用git将文件夹从一个分支合并到另一个分支

[英]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 . 它们是rcdev

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.

相关问题 Git合并(从一个分支合并到另一个分支) - Git Merge (merge from one branch to another) 我可以在git中将一个子文件夹从一个分支合并/同步到另一个分支的根吗? - Can I merge/sync a sub-folder from one branch to the root of another in git? git和合并。 从一个分支签出一个目录到另一个分支 - git and merge. Checkout one directory from one branch into another Git:将多个提交从一个分支合并到另一个分支 - Git : Merge multiple commits from one branch into another 是否可以仅使用某些文件从一个分支合并到git中的另一个分支? - Is it possible to merge from one branch to another in git with only certain files? 如何在git中将更改从一个分支合并到另一个分支 - How to merge changes from one branch to another in git Git合并时不包括从一个分支到另一个分支的提交 - Git merge without including commits from one branch to another 特定的增量需要在git上从一个分支合并到另一个分支 - specific delta need to merge on git from one branch to another 如何在 git 中将 2 个拉取请求从一个分支合并到另一个分支 - How to merge 2 pull requests from one branch to another in git Git:将文件夹从一个分支移动到 Node.js 中的另一个分支 - Git: Move a folder from one branch to another in Node.js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM