gpt4 book ai didi

git - 与传统的 VCS 相比,Git 基于快照的方法在实践中有哪些优点/缺点?

转载 作者:太空狗 更新时间:2023-10-29 13:46:50 25 4
gpt4 key购买 nike

在官方的 git 书中我可以读到这个:

Git thinks about its data more like a stream of snapshots. This is an important distinction between Git and nearly all other VCSs. It makes Git reconsider almost every aspect of version control that most other systems copied from the previous generation. This makes Git more like a mini filesystem with some incredibly powerful tools built on top of it, rather than simply a VCS. We’ll explore some of the benefits you gain by thinking of your data this way when we cover Git branching in Git Branching.

这在实践中有什么不同?书中说分支主题将涵盖这些好处,但那里没有提到,我不明白为什么这很重要。例如,我可以在 SVN 中创建分支,我可以创建补丁(如 cherry-pick )等等。那么为什么快照行为比 SVN 更有用呢?

请注意,我真的很喜欢 Git,我无意抨击它,我只是希望更好地理解它。

最佳答案

主要优势之一仍然是 merge ,这是 SVN 一直在挣扎的领域。
(参见“How and/or why is merging in Git better than in SVN?”)

你结合了graph of commits (DAG)表示分支(而不是 SVN 子树)和与每个提交关联的快照表示:

来自 Pro Git Book :

https://git-scm.com/book/en/v2/book/03-git-branching/images/basic-merging-1.png

Git does a simple three-way merge, using the two snapshots pointed to by the branch tips and the common ancestor of the two.

Instead of just moving the branch pointer forward, Git creates a new snapshot that results from this three-way merge and automatically creates a new commit that points to it. This is referred to as a merge commit, and is special in that it has more than one parent.

关于git - 与传统的 VCS 相比,Git 基于快照的方法在实践中有哪些优点/缺点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35043042/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com