3

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?

1
  • 2
    It sounds like you may be coming from an old version control system like source-safe. File locking is not the git way, perhaps this link may help: livefreeorscream.com/2009/…. Commented Jun 20, 2012 at 16:29

3 Answers 3

2

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.

Sign up to request clarification or add additional context in comments.

3 Comments

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.
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.
@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).
1

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.

Comments

0

You need a branch. Only you need this modifications? You do not need to share it with others. Create a local branch and work with it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.