Actually my question is:
Is there a way to merge from folder in master to root in branch?
What i want is:
- read-tree from branch to folder in master branch
- make some changes (add files in subtree folder) under master branch
- merge theese changes (added files) from subtree folder in master to branch root
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:
- New file 'fileInRack' in master branch in rack folder
- New file 'fileInRack' in root of rack_branch
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
you can do
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?