Can/should I fork my own github repo?

前端 未结 4 1087
迷失自我
迷失自我 2021-01-31 10:21

My github repo is called Programming-iOS-4-Book-Examples, because it\'s the example code from my book \"Programming iOS 4\". Now I\'ve written a new edition of the book, retitle

相关标签:
4条回答
  • 2021-01-31 10:58

    You can't have two repositories with the same name, and forking on Github automatically transfers the name, so that's what keeps that from working. It sounds like you would be well served by adding a branch locally, then pushing to a new Github repository with the new name. You can even keep the Github repo showing master as the branch:

    git clone git://github.com/you/repo.git
    git checkout -b new_book
    [ create new repo on Github ]
    git remote add new_origin git://github.com/you/repo.git
    git push new_origin new_book:master
    

    Just use more appropriate names and you're golden. You can merge updates to shared examples, add additional examples to the new book code, and you just push to both origin and new_origin (using the example names above) when you make changes.

    0 讨论(0)
  • 2021-01-31 11:09

    In the end here's what I did:

    1. I renamed the existing repo. This works great (thanks, github, for making that so easy). Don't forget to edit your own git repo's config file to keep the remote branch relationship between your own master branch and the github repo's master branch.

    2. I created a new repo with the old repo's name, consisting of nothing but a README.md providing the existing repo's new URL.

    Thus, I didn't end up separating the iOS 4 book content from the iOS 5 book content. Instead, I rearranged the structure of the original repo and gave it a more general name, not tied to iOS 4 in particular. And existing links to the old repo don't break, because there's a placeholder repo at that URL, pointing to the new repo.

    0 讨论(0)
  • 2021-01-31 11:14

    Given that you can have URL that link branches in a repo, you can still use branches, which INMHO are the natural and easy way for the case .

    For example, you can have the following URL for iOS4 example: https://github.com/mattneub/Programming-iOS-Book-Examples/tree/ios4

    And https://github.com/mattneub/Programming-iOS-Book-Examples/tree/ios5 for the iOS5 examples, where ios4 and ios5 are your branch names.

    0 讨论(0)
  • 2021-01-31 11:16

    I know this is old but I faced the same issue recently. What did work for me was the following:

    1. Create a new_repo at github
    2. git clone new_repo
    3. cd new_repo
    4. git remote add upstream old_repo.git
    5. git pull upstream master
    6. git push origin master

    I got all the above from here.

    0 讨论(0)
提交回复
热议问题