开发者

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

I'm getting a bit confused with Git!

  • I cloned a repo on GitHub to a local drive.
  • 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
  • I then did a git-push MyNewRepoOnGitHub master

Does MyN开发者_开发知识库ewRepoOnGitHub have everything that I originally cloned? 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?!


Your new repository on github will only contain all commits reachable from master (you only pushed master). To push all refs (including tags), use git push MyNewRepoOnGitHub --all.

I don't use github myself, but a pull request should be possible. Commits don't change when cloned or pushed (but it could be possible that github requires you to 'fork' the project first). Pulling and merging from your both your cloned repositories will definitely work (with plain 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. 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

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
  2. You email the original repo owner a patch and he applies and commits to the repo on your behalf
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜