How to upload a locally forked repository?

To explain a little better:

  • I locally cloned a repository (git clone https://github.com/jarun/nnn.git)
  • I made a branch for the changes
  • I made (trivial) changes to make it compile on macOS 10.11 (using mach_gettime.c)
  • I happily used it for some time
  • I merged origin\master that meanwhile had new commits into my branch
  • Works fine and I’d like to upload it to my account, in case it’s useful – and for backup

How do I upload to my github, so that it is a fork of the original project?
According to what I’ve read, I should first remove the link to the remote.
I suspect that would make it like it’s a new project, not tied to the original one.

Otherwise I can fork through github first, clone that and redo the changes – in this case no big deal, but I thought I’d ask for the future.

Yes, the fork should happen on GitHub, for several reasons. But you should still be able to save your current changes by simply updating your remotes. Right now, you should have only origin, which is pointing to the original repository. You should delete origin and recreate it, this time pointing to your fork on GitHub, and then add the upstream remote pointing to the original repository (i.e. what is now origin).

So you don’t need to delete your local repository, just update it references, then you’ll be able to push your branch with your custom changes to your fork (origin) and the open a pull request from GitHub WebUI.

1 Like

Git - Working with Remotes is highly recommended reading, except for creating a fork on the GitHub side it describes all the operations you need. :slightly_smiling_face:

A key thing to understand here is that your local repository can have as many remotes as you want, and their names don’t make any technical difference. If you clone a repository origin is just the default name for the remote you’re cloning from.

1 Like