We have 2 git branches - master and dev. The master contains files to be deployed to production and dev contains only files that needs modification.
At any point of time the master git branch will have 10+ files where as the dev will have only 1.
Now, the problem is if we merge master from dev it deletes all files and keeps only the 1 file that is available in the dev branch.
What we are looking for is to leave untouched all files from master and update only 1 file from dev (similar to rsync).
Any idea how we can implement delta merge in git?
It seems that dev
had all the files, and later at some time only 1 file was kept while others were deleted.
When you want to apply commits from dev
to master
, you can use git cherry-pick ${commit_from_dev}
.
If you intend to use git merge
, from the beginning, you should have created dev
as an orphan branch. In other words, dev
should share no history with master
when it's created.
# at the point of creating dev
git checkout --orphan dev master
git rm ${unwanted_files}
git commit -m 'init dev'
# the first time to merge dev
git checkout master
git merge dev --allow-unrelated-histories