简体   繁体   English

如果我推送一个克隆的 repo,它会拥有克隆 repo 的所有内容吗?

[英]If I push a cloned repo, will it have everything that the cloned repo has?

I'm getting a bit confused with Git!我对 Git 有点困惑!

  • I cloned a repo on GitHub to a local drive .我将 GitHub 上的存储库克隆到本地驱动器
  • I made some changes and committed to my local repo我做了一些更改并致力于我的本地仓库
  • At this point, I couldn't figure out how to clone my local repo to a new GitHub repo, so I went to GitHub.com and created a new repo with their web interface At this point, I couldn't figure out how to clone my local repo to a new GitHub repo, so I went to GitHub.com and created a new repo with their web interface
  • I then did a git-push MyNewRepoOnGitHub master然后我做了一个git-push MyNewRepoOnGitHub master

Does MyNewRepoOnGitHub have everything that I originally cloned? MyNewRepoOnGitHub是否包含我最初克隆的所有内容? Can I send a pull request to the contributors of the project that I originally cloned?我可以向我最初克隆的项目的贡献者发送拉取请求吗? Or... am I being completely thick and need to reread what I thought I knew about Git?!或者......我是不是太厚了,需要重新阅读我认为我知道的关于 Git 的内容?!

Your new repository on github will only contain all commits reachable from master (you only pushed master).您在 github 上的新存储库将仅包含可从master访问的所有提交(您只推送了 master)。 To push all refs (including tags), use git push MyNewRepoOnGitHub --all .要推送所有引用(包括标签),请使用git push MyNewRepoOnGitHub --all

I don't use github myself, but a pull request should be possible.我自己不使用 github,但应该可以使用拉取请求。 Commits don't change when cloned or pushed (but it could be possible that github requires you to 'fork' the project first).克隆或推送时提交不会更改(但 github 可能要求您首先“分叉”项目)。 Pulling and merging from your both your cloned repositories will definitely work (with plain git)从您的两个克隆存储库中提取和合并肯定会起作用(使用普通 git)

I think you will have to explicitly "fork" the original repo to raise a pull request.我认为您必须明确地“分叉”原始存储库以提出拉取请求。 Github currently doesn't know that your MyNewRepoOnGitHub is related to the original repo you cloned from. Github 目前不知道您的MyNewRepoOnGitHub与您从中克隆的原始存储库相关。 Forking establishes this relation and allows for pull requests to be raised to share commits.分叉建立了这种关系,并允许提出拉取请求以共享提交。

You can:你可以:

  1. Fork the original repo from which you cloned分叉您从中克隆的原始存储库
  2. Setup the forked repo as an additional remote repository (for the existing cloned repo on your machine)将分叉的存储库设置为附加的远程存储库(用于您机器上现有的克隆存储库)

     git remote add MyForkedRepo <url-to-your-forked-repo>
  3. Push your changes to the forked repo将您的更改推送到分叉的仓库

     git push MyForkedRepo master
  4. Raise a pull request on Github在 Github 上提出拉取请求

Without forking there are two ways, albeit very ancient looking compared to the pull request approach,没有分叉,有两种方法,尽管与拉取请求方法相比看起来非常古老,

  1. The original repo commiter/owner will have to add your MyNewRepoOnGithub as his remote and pull your changes and merge them and push them the original repo原始回购提交者/所有者必须将您的MyNewRepoOnGithub添加为他的远程并提取您的更改并合并它们并将它们推送到原始回购
  2. You email the original repo owner a patch and he applies and commits to the repo on your behalf您 email 原始回购所有者一个补丁,他代表您申请并提交回购

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM