Git - don't merge deletes
I've a branch develop
with files:
- index.php
- test.php
I'm creating branch release
from it, where I set versions, make small bugfixes, etc, and delete test.php which doesn't go into production release. Then I want to merge this branch into develop
but want to keep test.php in 开发者_如何学运维develop branch. How to do it? Default behaviour of git merge
just deletes the file.
1/ I would rather rebase develop branch (if you haven't pushed it to a remote repo yet) on top of master, to make sure all my development is still compatible with the latest release (and all its bug-fixes).
If your current development is really different from release (massive refactoring), then and only then I would consider cherry-picking the bug-fixes.
2/ If a file needs to be kept as is during a merge, you can set a merge manager in a .gitattribute
file only in the develop branch.
The conventional wisdom is that you never merge from a release branch into a development branch. Instead, apply the bugfixes commits to the development branch using git cherry-pick
.
精彩评论