[英]git merge from subtree folder in master to branch root
Actually my question is: 其实我的问题是:
Is there a way to merge from folder in master to root in branch ? 有没有一种方法可以从主文件夹合并到分支的根目录?
What i want is: 我想要的是:
I've tried this tutorial: https://git-scm.com/book/en/v1/Git-Tools-Subtree-Merging 我已经尝试过本教程: https : //git-scm.com/book/en/v1/Git-Tools-Subtree-Merging
But results are unexpected: 但是结果出乎意料:
I did: 我做了:
$ git init
$ touch fileInMaster
$ git add -A
$ git commit --all -m 'initial commit'
$ git checkout master
$ git remote add rack_remote https://github.com/schacon/rack.git
$ git fetch rack_remote
$ git checkout -b rack_branch rack_remote/master
$ git checkout master
$ git read-tree --prefix=rack/ -u rack_branch
$ git add -A
$ git commit --all -m 'After read-tree to rack folder'
$ echo 0 > rack/fileInRack
$ git add -A
$ git commit --all -m 'Add fileInRack file to rack folder'
$ git merge --squash -s subtree --no-commit rack_branch
What i'm expect is: 我期望的是:
But after subtree merging git notice me: 但是在合并git的子树之后,请注意:
Deleting rack/fileInRack 删除机架/ fileInRack
Squash commit -- not updating HEAD 壁球提交-不更新HEAD
Automatic merge went well; 自动合并进展顺利; stopped before committing as requested 在按要求提交之前已停止
But i need adding, not deleting. 但是我需要添加,而不是删除。
So, what am i doing wrong? 那么,我在做什么错呢?
Is there other way to merge from folder in master to root in branch ? 还有其他从主文件夹合并到分支根的方法吗?
Instead of 代替
git merge --squash -s subtree --no-commit rack_branch
you can do 你可以做
git checkout rack_branch
git merge --squash -s recursive -Xsubtree --allow-unrelated-histories master
git commit -m "commit fileInRack to rack_branch"
EDIT: The reason I stumbled across this post is that I have a similar problem, and my solution above doesn't work ( see here ). 编辑:我偶然发现这篇文章的原因是我有一个类似的问题,并且上面的解决方案不起作用( 请参阅此处 )。 Note the edit about the --no-ff
option. 注意有关--no-ff
选项的编辑。 It may be a good idea to always use this option? 始终使用此选项可能是一个好主意?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.