Git 分叉实际上是 Git 克隆吗? [英] Are Git forks actually Git clones?

查看:30
本文介绍了Git 分叉实际上是 Git 克隆吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直听到人们说他们在 Git 中分叉代码.Gitfork"听起来很可疑,就像 Gitclone"加上一些(无意义的)心理愿意放弃未来的合并.Git 里没有 fork 命令吧?

GitHub 通过在分叉上装订信件使分叉更加真实.也就是说,您按下 fork 按钮,稍后,当您按下 pull request 按钮时,系统足够智能,可以向所有者发送电子邮件.因此,它有点像围绕存储库所有权和权限的舞蹈.

是/否?对 GitHub 朝这个方向扩展 Git 有任何焦虑吗?或者有没有关于 Git 吸收该功能的传言?

解决方案

.

I keep hearing people say they're forking code in Git. Git "fork" sounds suspiciously like Git "clone" plus some (meaningless) psychological willingness to forgo future merges. There is no fork command in Git, right?

GitHub makes forks a little more real by stapling correspondence onto it. That is, you press the fork button and later, when you press the pull request button, the system is smart enough to email the owner. Hence, it's a little bit of a dance around repository ownership and permissions.

Yes/No? Any angst over GitHub extending Git in this direction? Or any rumors of Git absorbing the functionality?

解决方案

Fork, in the GitHub context, doesn't extend Git.
It only allows clone on the server side.

When you clone a GitHub repository on your local workstation, you cannot contribute back to the upstream repository unless you are explicitly declared as "contributor". That's because your clone is a separate instance of that project. If you want to contribute to the project, you can use forking to do it, in the following way:

  • clone that GitHub repository on your GitHub account (that is the "fork" part, a clone on the server side)
  • contribute commits to that GitHub repository (it is in your own GitHub account, so you have every right to push to it)
  • signal any interesting contribution back to the original GitHub repository (that is the "pull request" part by way of the changes you made on your own GitHub repository)

Check also "Collaborative GitHub Workflow".

If you want to keep a link with the original repository (also called upstream), you need to add a remote referring that original repository.
See "What is the difference between origin and upstream on GitHub?"

And with Git 2.20 (Q4 2018) and more, fetching from fork is more efficient, with delta islands.

这篇关于Git 分叉实际上是 Git 克隆吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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