例如,我有一个这样的项目分支主管:
project_folder
|
|---a.txt
|---b.txt
|---c.txt
|---folder1
|---sub_a.txt
|---sub_b.txt
|---sub_c.txt
并像这样分支一个
project_folder
|
|---a.txt
|---b.txt
|---c.txt
|---folder1
|---sub_a.txt
并像这样分支b
project_folder
|
|---a.txt
|---b.txt
|---c.txt
|---folder1
|---sub_b.txt
...
我希望将master和a与所有文件合并,sub_b.txt,sub_c.txt除外。与合并master和b相同 PS:它将像xxx.txt
这样的新文件添加到folder1
答案 0 :(得分:1)
合并时,您不能忽略文件。您可以使用--no-commit选项合并,以在合并后检查更改,而不是自动提交。
git checkout a
git merge --no-commit master
git rm folder/sub_b.txt #to not consider this file for commit
git rm folder/sub_c.txt #to not consider this file for commit
git commit -m "merge of master to branch a"
也对分支b重复相同的操作。
git checkout b
git merge --no-commit master
git rm folder/sub_b.txt #to not consider this file for commit
git rm folder/sub_c.txt #to not consider this file for commit
git commit -m "merge of master to branch b"