git branch,fork,fetch,merge,rebase和clone之间有什么区别?

git branch,fork,fetch,merge,rebase和clone之间有什么区别?

问题描述:

我想了解Git中分支,分支和克隆之间的区别吗?

I want to understand the difference between a branch, a fork and a clone in Git?

类似地,当我执行git fetch而不是git pull时,这是什么意思?

Similarly, what does it mean when I do a git fetch as opposed to a git pull?

此外,与merge相比,rebase是什么意思?

Also, what does rebase mean in comparison to merge?

我如何将个人共同压榨在一起?

How can I squash individual commits themselves together?

它们如何使用,为什么使用以及它们代表什么?

How are they used, why are they used and what do they represent?

GitHub如何参与进来?

How does GitHub figure in?

克隆只是存储库的副本.从表面上看,它的结果等效于svn checkout,您可以在其中从其他存储库下载源代码.集中式VCS(例如Subversion)和DVCS(例如Git)之间的区别在于,在Git中,克隆时,您实际上是在复制整个源存储库,包括所有历史记录和分支.现在,您的计算机上有了一个新的存储库,您所做的所有提交都进入该存储库.除非您将这些提交推送到另一个存储库(或原始存储库),或者有人可以从您的存储库中提取提交(如果它是可公开访问的),那么没人会看到任何更改.

A clone is simply a copy of a repository. On the surface, its result is equivalent to svn checkout, where you download source code from some other repository. The difference between centralized VCS like Subversion and DVCSs like Git is that in Git, when you clone, you are actually copying the entire source repository, including all the history and branches. You now have a new repository on your machine and any commits you make go into that repository. Nobody will see any changes until you push those commits to another repository (or the original one) or until someone pulls commits from your repository, if it is publicly accessible.

分支是存储库中的东西.从概念上讲,它代表着发展的脉络.通常,您有一个master分支,但也可能有一个分支,您正在其中从事某些功能xyz的工作,而另一个分支则用于修复错误abc.签出分支后,所做的所有提交都将保留在该分支上,并且与其他分支合并或将它们重新建立到相关分支之前,不会与其他分支共享该提交.当然,在谈到分支之前,Git似乎有点怪异,直到您了解实现分支的基础模型为止.我不会自己解释它(我已经说了太多,methinks),而是链接到有关Git如何建模分支和提交的计算机科学"解释,该解释取自Git网站:

A branch is something that is within a repository. Conceptually, it represents a thread of development. You usually have a master branch, but you may also have a branch where you are working on some feature xyz, and another one to fix bug abc. When you have checked out a branch, any commits you make will stay on that branch and not be shared with other branches until you merge them with or rebase them onto the branch in question. Of course, Git seems a little weird when it comes to branches until you look at the underlying model of how branches are implemented. Rather than explain it myself (I've already said too much, methinks), I'll link to the "computer science" explanation of how Git models branches and commits, taken from the Git website:

http://eagain.net/articles/git-for-computer-scientists/

叉子实际上不是Git概念,而是一个政治/社会概念.就是说,如果有些人对项目的发展方式不满意,他们可以独立于原始开发人员而采用源代码并自己进行处理.那将被认为是叉子. Git使分叉变得容易,因为每个人都已经拥有了自己的源代码主"副本,因此就像与原始项目开发人员建立联系一样简单,并且不需要像使用SVN那样从共享存储库中导出历史记录

A fork isn't a Git concept really, it's more a political/social idea. That is, if some people aren't happy with the way a project is going, they can take the source code and work on it themselves separate from the original developers. That would be considered a fork. Git makes forking easy because everyone already has their own "master" copy of the source code, so it's as simple as cutting ties with the original project developers and doesn't require exporting history from a shared repository like you might have to do with SVN.

由于我不知道GitHub等网站所使用的"fork"的现代定义,因此请查看注释以及

since I was not aware of the modern definition of "fork" as used by sites such as GitHub, please take a look at the comments and also Michael Durrant's answer below mine for more information.