在 SVN 中,您可以 Check Out(以阻止其他人),您可以在 GIT 中执行此操作吗?
在 SVN 中,您可以签出(以阻止其他人处理同一文件)。你能在 GIT 中做到这一点吗?看来你必须建立第二个系统来告诉人们哪些文件正在由谁使用 GIT 编辑?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Git 没有中央存储,您可以通过查询来检查文件是否被“锁定”。由于其分布式特性,一个存储库可以位于 1,000 台计算机上,而且它们都是平等的。如果您允许他们所有人锁定一个文件,并且让他们将此信息传达给所有其他存储库,那么所有文件基本上都会被锁定。
所以不,你不能在 Git 中这样做。相反,依靠经常更新并处理奇怪的合并冲突。
您可以阅读维基百科上的分布式版本控制系统。
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.
这对于 DVCS 来说没有多大意义(如“分布式”),
您所能做的就是设置一个“中央”存储库,它不接受非快进推送,这会让您在推送之前先重新调整工作基础到所说的“中央”回购。
但同样,VCS 中没有“锁定”的概念,您可以将所有历史记录存储在本地,并且可以与所有其他“服务器”VCS 完全隔离。
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.
在 git(或任何分布式版本控制系统)中,问题不是“你能锁定文件吗?”,而是“为什么有人会使用锁定文件是必要或可取的 VCS?” DVCS 的工作流程/思维方式使得操作完全毫无意义。这类似于询问如何在所有 1000 个不同的机器上锁定 /etc/password,而您甚至不知道要使用哪些机器。
您不能通过阻止其他开发人员编辑其文件副本来控制他们的访问权限。您可以通过决定将哪些补丁拉入代码副本来控制访问。
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.