We are a team of 60+ developers working on the same product and are moving from SVN to Git and GitHub. We have a process in SVN where in individual files are locked and when
You can use LFS and you could lock individual files, or instead jus add the files to .gitattributes file,
https://github.com/git-lfs/git-lfs/wiki/File-Locking
Git does not provide any locking functionality, since it is decentralized. However, if you host your code on GitLab Enterprise Edition Premium, you can use the web interface to lock individual files or folders, achieving exactly what you want to do.
If you do not want to host your project on someone else's server (their website), you can also download GitLab and host it on your own webserver.
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.
This use case is one of the reasons Git is so much better than SVN --> rebase! If you follow good git workflow you rebase from upstream before submitting your Pull Requests. You don't need to worry about file locking and stomping on another person's commits and merge conflicts etc... a rebase sets your work aside, applies the remote commits and then applies your work on top.
I think this just takes a rethinking in your process and relying on the strengths of git versus force fitting a Subversion workflow on top of git. Your "fork-clone" model might need another look as well. Most often every developer has their own fork, you can share repos via remotes between teams if you want. But contributors sharing the same origin sets up some bad habits.
Gitflow is a very popular git workflow, and Github themselves has some nice tips and shares their workflow.
There is no way of doing it in Git. As others said, if the document is "mergable", you can try rebasing, changing the way you act.
In our case, we have a convention: if you REALLY need to lock it, rename it. But we only do such things in office documents, etc.
This constribution is not giving a solution, it is a workaround trick (but stackoverflow does not allow me to add this as a comment.
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
.