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
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:
Deleting rack/fileInRack
Squash commit -- not updating 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. It may be a good idea to always use this option?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.