git分支,叉,取,合并,重定位和克隆有什么区别? [英] git branch, fork, fetch, merge, rebase and clone, what are the differences?

查看:242
本文介绍了git分支,叉,取,合并,重定位和克隆有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



同样的,当我做一个 git fetch ,而不是 git pull

另外,与 merge rebase >?



我怎样才能压缩个人承诺?

他们如何使用,他们为什么被使用,它们代表什么?



GitHub如何显示?

克隆只是一个存储库的副本。从表面上看,它的结果相当于 svn checkout ,您从其他仓库下载源代码。像Subversion这样的集中式VCS和Git之类的DVCS之间的区别在于,在Git中,当你克隆时,你实际上正在复制整个源代码库,包括所有的历史和分支。现在,您的计算机上已经有了一个新的存储库,并且您提交的任何提交进入该存储库。没有人会看到任何变化,直到你将这些提交推送到另一个存储库(或原始存储库),或者直到有人从你的存储库中提取提交(如果它是可公开访问的)。



分支是存储库内的东西。从概念上讲,它代表了一种发展的线索。您通常拥有一个主分支,但您也可能有一个分支,您正在使用某些功能xyz,另一个分支修复bug abc。当您签出分支时,您提交的任何提交将保留在该分支上,并且不会与其他分支共享,除非您将其合并或重新绑定到相关分支上。当然,就分支而言,Git似乎有点不可思议,除非您查看实现分支的基本模型。我没有自己解释(我已经说了太多,methinks),我将链接到Git模型分支和提交的计算机科学解释,从Git网站获取:



http://eagain.net/articles/git-for - 计算机科学家/



分叉实际上不是Git的概念,它更像是一个政治/社会的想法。也就是说,如果有些人对项目进行的方式不满意,他们可以将源代码与原始开发人员分离开来。这将被视为分叉。 Git让分叉变得容易,因为每个人都拥有自己的主副本的源代码,所以它就像切断与原始项目开发人员的联系一样简单,并且不需要从共享存储库导出历史记录,就像您可能需要使用SVN 。

编辑:由于我没有意识到像GitHub这样的网站使用的fork的现代定义,请看看评论和迈克尔达兰特的答案下面我的详细信息。


Can someone help me understand the difference between a branch, a fork and a clone in Git?

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

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?

How does GitHub figure in?

解决方案

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.

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/

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.

EDIT: 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.

这篇关于git分支,叉,取,合并,重定位和克隆有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆