简体   繁体   中英

Append changes in git for some files

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?

eg 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

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM