Fork and rename a repo

I have a repo on my home computer, which I used to test some modules which are in private GitHub repos that my boss can see. I want to fork it into a new repo, which will go into another GitHub repo that my boss can see, keeping the history, and then delete the test code and make the main program for a demo. How can I do this, generating a new UUID and whatever else is needed?

I’m not 100% clear what you’re trying to accomplish. So maybe it would be helpful for you to share a bit more about what the current state is and what’s different about what you would like it too be.

“Forking” is really just copying (or cloning, which amounts to the same thing) the directory - in GitHub parlance, it’s what they call “clone a repo from one user/org to another user/org” - functionally it’s the same as of you cloned to your local computer, made a new repo, then set that as the remote and pushed.

If the main goal is just to save the state of the current repo while you make some radical changes, just tag the current commit and keep going!

If the goal is to go from a state where everything is private to a state where it’s public, you can just make the repo public. You said explicitly that you want to retain the history, so switching to a different repo will be no different.

Unless you meant that you want to save the history in private and start a new repo in public without the history. In which case the easiest thing to do is to delete the .git directory, then do a new git init and set a new GitHub repo as a remote.

I don’t know if any of this implicates Julia - unless you want to install both the old and new editions of the package in the same environment, or have them in some shared registry, you didn’t even need to change the uuid.

5 Likes

I’m going to rename the repo, move the functions that don’t belong to another repo, and put it on a private GitHub repo.

That seems fine. One thing to note is that git itself doesn’t know “the name” of the repo, that is, the directory that it’s in. You can rename the directory all you want and it doesn’t affect the contents.

The repo name on GitHub obviously matters for the url, but if you simply rename they set up some forwarding by default I think - I don’t know what happens if you try to make another repo of the same name.

I’d encourage you to consider if you actually need to do this though. Are the test functions / early prototypes really bad to have in the history? Only you know the answer, and there are also other totally legit reasons to want a fresh start (eg if you committed a bunch of large files you didn’t need, they’ll get pulled along every time you clone), but I’ve found git histories to be very useful, and usually they don’t cost anything.