Merge Branch into a Directory GIT

Viewed 37

I have main branch named Project

Then I have a branch named payment which consists all the project files of the application

I want to merge the branch payment into my main branch but inside a folder/directory

In other words Project branch -> Payment Application(folder) -> files of the payment branch

1 Answers

First time:

git checkout project
git merge --no-commit -s ours payment
git read-tree -u --prefix=payment/ payment
git commit

Thereafter:

git checkout project
git merge -s subtree payment

and you're probably fine making that the default merge strategy for your project branch, puns seem unlikely:

git config branch.project.mergeoptions '-s subtree'
Related