Search code examples
gitatlassian-sourcetreesourcetree

Making a file read only in Git or SourceTree


Let's say I have a repo that looks like this:

Repo  
--a.txt  
--b.txt

Let's say I create a feature branch named featureA for user A to implement a feature. After implementing feature branch would be merged back to master.

Now I want User A to work only with b.txt to implement the feature and not change a.txt but as far as I have seen user can change a.txt. So how do I restrict the user from changing a.txt? Also, I want a.txt to be in user's copy but I don't want the user to change it. Can this be done in Git or SourceTree?


Solution

  • Git's submodule is the one you need:

    • Create a different repo, let's call it different_repo lol.
    • Add a.txt to different_repo.
    • Add different_repo to your current repo as a submodule.
    • Remember to setting different_repo to read-only to some of your users.
    • Cheers.