Is there a way to lock individual files or directories on fork when using git?
this is possible. git-lfs 2.0 introduces the ability to lock files: see these links: https://github.com/git-lfs/git-lfs/wiki/File-Locking. Support for this feature is available starting from TFS 2017.2: https://docs.microsoft.com/en-us/vsts/release-notes/.
Not exactly locking, but Github has introduced a concept called "Code Owners". Allows you to restrict part of your codebase to only allow commits after review by the code owners
No chance, if file is not mergeable and you need to lock it, use a centralized solution instead of GIT, i.e. SVN or ClearCase.
If you are using git LFS
(which is supported by some git hosting providers, like GitHub) you could use File Locking.
Mark a file type as lockable by editing the .gitattributes
file:
*.docx lockable
# Make MS Word files lockable
And lock it with:
$ git lfs lock example.docx
You can unlock your files with git lfs unlock example.docx
and those of somebody else by adding --force
.