galymzhan
galymzhan

Reputation: 5523

Git - don't merge deletes

I've a branch develop with files:

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.

Upvotes: 1

Views: 598

Answers (2)

VonC
VonC

Reputation: 1323953

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.

Upvotes: 3

cdhowie
cdhowie

Reputation: 168998

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.

Upvotes: 2

Related Questions