Is there a way to lock a file when working with Git? Or how would I go about and notify co-workers that I'm currently changing a Java class so that they don't start working on it? Is there something in Git to prevent something like this to happen?
3 Answers
Ideally you'd be able to edit the file while co-workers also edit it, and git will help you merge your changes together. File locking isn't something Git allows, they favor good communication and collaboration instead.
3 Comments
Shahbaz
Exactly. Also,
git merge makes life so easy, that even if there are merge conflicts, it is very easy to resolve them. Nevertheless, even if two people change different parts of the same file git can still successfully merge them.cherrun
Ok. I guess communication is the key here. I just don't want to have people implementing the same stuff someone else is doing already.
Robin Green
@cherrun If you use Scrum and have a task board with index cards (physical or in software), and move the cards as soon as a task is completed, everyone can easily see what other people are working on at any given time. Of course you don't need to adopt the whole of Scrum for this (Kanban is a simpler methodology which also has a board).
No, it's not possible to lock files in Git, but Veracity is an alternative to Git that supports locking. However, even there, it is intended to be used for binary files, not text files.