I\'m using Git on a new project that has two parallel -- but currently experimental -- development branches:
master
: import of existing codebase pl
If you only need to merge a particular directory and leave everything else intact and yet preserve history, you could possibly try this... create a new target-branch
off of the master
before you experiment.
The steps below assume you have two branches target-branch
and source-branch
, and the directory dir-to-merge
that you want to merge is in the source-branch
. Also assume you have other directories like dir-to-retain
in the target that you don't want to change and retain history. Also, assumes there are merge conflicts in the dir-to-merge
.
git checkout target-branch
git merge --no-ff --no-commit -X theirs source-branch
# the option "-X theirs", will pick theirs when there is a conflict.
# the options "--no--ff --no-commit" prevent a commit after a merge, and give you an opportunity to fix other directories you want to retain, before you commit this merge.
# the above, would have messed up the other directories that you want to retain.
# so you need to reset them for every directory that you want to retain.
git reset HEAD dir-to-retain
# verify everything and commit.