views:

152

answers:

3

In SVN you can Check Out (to block others from working on the same file). Can you do this in GIT? It seems like you have to set up a second system that tells people what files are being edited by who with GIT?

+5  A: 

That would not make a lot of sense with a DVCS (as in "Distributed")

All you can do is set a "central" repo which would not accept non-fast forward push, which would make you rebase your work first before pushing it to said "central" repo.

But again, there is no notion of "lock" in a VCS where you have the all history stored locally and can work in complete isolation from all the other "servers" VCS.

VonC
See also http://stackoverflow.com/questions/2171823/svn-monitor-like-software-for-git-repositories/2171914#2171914
VonC
+11  A: 

Git doesn't have a central store that you can query to check if a file is "locked". Due to its distributed nature, a repository could be on 1,000 computers, and they'd all be equal. If you allowed all of them to lock a file, and for them to communicate this to all other repositories, all files would basically be locked all the time.

So no, you can't do that in Git. Instead, rely on updating often and handling the odd merge conflict.

You can read about distributed version control systems on Wikipedia.

Blixt
+2  A: 

In git (or any distributed version control system) the question is not "can you lock a file?", but "why would anyone use a VCS in which locking a file is necessary or desirable?" The work flow/mindset of a DVCS simply makes the operation completely non-sensical. It's similar to asking how you can lock /etc/password on all of 1000 different boxes when you don't even know which boxes you want to work with.

You don't control other developer's access by preventing them from editing their copy of the file. You control access by deciding which patches to pull into your copy of the code.

William Pursell
Locking a file is useful when the file contains content that is not human readable, and thus cannot be merged. Do DVCS' have any mechanism for dealing with files that cannot be merged?
RjOllos