Limited file access

Please tell me how best to organize the following logic for working with the repository. I have a repository branch in which all the project files are located. Dev1 works with this branch and has full access to all files in it. I need to connect dev2 to the repository so that it has access only to files that are in several separate repository folders. To automatically combine the changes of both individual lines and the different contents of certain lines that dev1 and dev2 add to the same files during the day. For example, in the sample.html file there is a tag <div id="sample">

  • dev1 on its local host assigns the class “dev1”
  • dev2 on localhost assigns the class “dev2” to it
    As a result, the union of their commits should be <div id "sample" class= "dev1 dev2">