Can/should I fork my own github repo?
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, retitled “Programming iOS 5”. I need to leave the old repo in place with the old name, because there are links to it all over the net and someone might need the old code. But now I also want a new repo with a new name, Programming-iOS-5-Book-Examples, containing the same examples rewritten for iOS 5 (plus some new ones).
Naturally, I saw this: How can I fork my own GitHub repository? But the advice there is to use branches. That isn’t going to work for me. I don’t want to use a branch because that defeats the purpose of giving the repo a name that I can link to. I want the public to find my iOS 4 examples in the iOS 4 repo and my iOS 5 examples in the iOS 5 repo.
- How do I use github tags to create downloads for my project?
- Git/hub submodule: track upstream & modify without missing commits
- git did not exit cleanly (exit code 128)
- How to find conflicts in a pull request
- How to use a “private” .xcconfig in a “Shared” (git-managed) Xcode project?
- What is the difference between 'origin' and the newly created repository in github?
This seems like a perfect use of a fork, but when I press the Fork button nothing happens; I’m apparently not allowed to fork my own repo.
Of course I could just make this a whole new repo, but that would mean uploading all the resources separately, which is unfortunate because everything is already right there in the iOS 4 repo. Do I just have to do that anyway?
4 Solutions collect form web for “Can/should I fork my own github repo?”
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
new_origin (using the example names above) when you make changes.
I know this is old but I faced the same issue recently. What did work for me was the following:
- Create a new_repo at github
- git clone new_repo
- cd new_repo
- git remote add upstream old_repo.git
- git pull upstream master
- git push origin master
I got all the above from here.
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:
And https://github.com/mattneub/Programming-iOS-Book-Examples/tree/ios5 for the iOS5 examples, where
ios5 are your branch names.
In the end here’s what I did:
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
configfile to keep the remote branch relationship between your own master branch and the github repo’s master branch.
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.