Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you fork your own repository on GitHub?

I have a public repository on GitHub. I want to replicate/copy it and work on a new project based on this repository, but I don't want to affect how it is now. I tried forking it using the GitHub UI but it didn't do anything.

like image 767
WowBow Avatar asked Sep 26 '22 15:09

WowBow


People also ask

How do I fork a GitHub repository in GitHub?

To follow along, browse to a public repository that you want to fork. At the top right of the page, you will find the Fork button. Click on the button and wait for a few seconds. You will see that the newly forked repository gets created under your GitHub account.

How do I fork a repo in Git?

If you need to fork a GitHub or GitLab repo, it's as simple as navigating to the landing page of the repository in your web browser and clicking on the Fork button on the repository's home page. A forked copy of that Git repository will be added to your personal GitHub or GitLab repo. That's it.


2 Answers

I don't think you can fork your own repo.
Clone it and push it to a new repo is good but you need to:

git clone https://github.com/userName/Repo New_Repo
cd New_Repo
git remote set-url origin https://github.com/userName/New_Repo
git remote add upstream https://github.com/userName/Repo
git push origin master
git push --all

(see git push)

See the all process described at "Fork your own project on GitHub".


Six years later (2016), you now have the GitHub importer which allows you to import a repo from another source... including GitHub.
See "Importing a repository with GitHub Importer"

https://help.github.com/assets/images/help/importer/import-repository.png

narf's answer (upvoted) also illustrate that process.

That will allow you to create a new repository and import the full history of the old one into the new one, using its GitHub url.

Again: what you get is a copy, not a real fork: you cannot make pull request from the new repo to the old one.

Again (bis), as stated in the comments by mpersico, this is not a TRUE FORK.

If I have a foo which is the canonical source repo for an open source project that I want other people to fork and have access to do PR, then I do not want to work in that repo, I want a fork I can use to issue proper PRs against my project.
I have solved this my creating a second account in GitHub and forking to that.

like image 277
VonC Avatar answered Oct 13 '22 03:10

VonC


A super easy way to do it in 30 seconds from the GitHub website:

  1. Copy your repo's URL. Ex: https://github.com/YourName/YourOldRepo (hint: it's the URL when you look at your repo's main page on github.
  2. Click the + icon in the top right corner.
    https://i.stack.imgur.com/9zJgo.png
  3. Select "Import repository".
  4. Where it asks for the "Old URL", paste the URL you copied at step #1
    https://i.stack.imgur.com/vgWd3.png
  5. Enter the name of your new repo and click Begin Import.
  6. That's it! You now have a copy of the full repo, with all commit history and branches!

Limitations: It's not actually a real fork. It's a copy of the repo. It won't allow to do pull requests back and forth.

like image 170
narF Avatar answered Oct 13 '22 04:10

narF