I need to merge between dev and master frequently.
I also have a commit that I need to apply to dev only, for things to work locally.
Earlier I only merged from dev to master, so I had a branch production_changes that contained the “undo commit” of the dev special commit. and from the master, I merged this. Used to work fine.
Now each time I merge from dev to master and vice versa, I am having to cherry-pick and apply the same commit again and again :(. Which is UGLY.
What strategy can I adapt so that I can seamlessly merge between 2 branches, yet retain some of the changes only on one of those branches?
I would recommend a merge driver (scripts declared in a merge directive within a
.gitattributesfile) in order to prevent certain files to be affected by a given commit.(for instance, if certain files must not be modified, that driver would be as simple as a “keep mine” merge. That has been used to merge only specific directories by example, or to track how config files are managed per branch.)
THE OP adds:
Clever solution?…
Well I can propose
git rerere(reuse recorded resolution of conflicted merge: if you merge to dev trigger a conflict, and if the resolution of that conflict is you effectively cancelling that merge, you can record that resolution, in order to have it automatically repeated during the next merge.See Rerere Your Boat… by Scott Chacon for more in this command.