[英]how to merge all files from one branch to another branch but except one file
认为,
一科:
file1,
No-add-another-branch
file3
另一个分支:
file1,
file2,
....
我想将一个分支中的所有文件合并到另一个分支中,除了“No-add-another-branch”文件。
我可以将“No-add-another-branch”文件移动到某个地方并将一个分支合并到另一个分支,但我正在寻找一种快捷方式。 或 git 方式。
No-add-another-branch
)No-add-another-branch
阶段删除(使用git rm No-add-another-beanch
)git commit --amend
)另一种方法是在合并之前删除临时分支中的文件。 这会创建一个额外的提交,但会使合并更清晰,并且历史记录将更容易阅读。
git checkout -b tmp OneBranch
git rm No-add-another-branch
后跟git commit -m 'Remove the file before merging
git checkout AnotherBranch
和git merge tmp
git branch -d tmp
历史应该是这样的:
o--o--o--o Another Branch
/
o Remove the file before merging
/
o--o--o One Branch
如果您不想删除文件,而是希望保持文件不变,您可以将第一种方法的步骤 2 替换为git checkout AnotherBranch^ -- No-add-another-branch
(即,在合并之前恢复其先前版本) ,或将第二种方法的步骤 2 替换为git checkout AnotherBranch -- No-add-another-branch
followed by git commit -m 'Make the file equal to Another Branch before merging'
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.