Reputation: 163
I have a repo with master and feature branch. I would like to know if there is a way to merge the feature branch as a new sub directory under the master branch.
Thanks!
Upvotes: 3
Views: 719
Reputation: 15540
git am
has a --directory=<dir>
switch, so you tell which directory to use as the base of the applying patches.
So, first make a git format-patch
and then apply them:
$ git checkout master
$ git format-patch -o ../patches/ master..feature-branch
$ git am --directory=feature-subdir ../patches/*
--directory=<dir>
is passed to git apply
by git am
. From git help apply
:
--directory=<root>
Prepend <root> to all filenames. If a "-p" argument was also passed, it is applied before prepending the new root.
For example, a patch that talks about updating a/git-gui.sh to b/git-gui.sh can be applied to the file in the working tree modules/git-gui/git-gui.sh by running git apply
--directory=modules/git-gui.
Upvotes: 3
Reputation: 18706
Yes you can. Simply move the content of the feature branch to a directory, then merge it with master.
Upvotes: 0