Reputation: 5736
Hi I have a git file that I do not want changes to be merged into it, instead, I want changes to be always appending to the end of the file, while the rest of the project files are merging as normal. Is this configurable in git?
e.g. In the upstream a file F has one line
1. |10-09-2016 00:12:43 : Check completed
In my fork, I changed F to
1. |11-09-2016 00:10:55 : Check completed
Then I submit my change and create a MR from my fork to the upstream.
Instead of changing the file F on upsteam to
1. |11-09-2016 00:10:55 : Check completed
I want the file F on upsteam, after accepting the MR, to become
1. |10-09-2016 00:12:43 : Check completed
2. |11-09-2016 00:10:55 : Check completed
Upvotes: 5
Views: 552
Reputation: 1323343
You can try and define a custom merge manager, which will aggregates the two versions in the case of a merge conflict.
You can see a full example here: "strategy for git and append-mostly files"
You will also see alternatives for you to try, like adding in a .gitattributes
:
myfile merge=union
No merge driver needed in that case.
union
Run 3-way file level merge for text files, but take lines from both versions, instead of leaving conflict markers.
This tends to leave the added lines in the resulting file in random order and the user should verify the result. Do not use this if you do not understand the implications.
(That is not "appending" the other version though)
Upvotes: 2