Search code examples
gitgithubgit-forkgit-fetch

How to fetch a remote branch from forked repo to local, and currently forked repo from which branch is pushed is not exist


My coworker has forked a foreign repository, pushed some changes to the fork and created a pull request. Now the forked repository does not exist any longer.

Now I want to fetch a remote branch which was created by the non existent forked repository. I also want to add some changes to the pull request. But as the user/forked repository is not existent, how can I fetch the branch and push the changes?


Solution

  • If the upstream repository does not exist any longer there will be no chance to fetch from it. Also there is no point in creating a PR to a non existent repository as no one will ever integrate it.

    What you can do - given the original license allows it - is create a new repository hosting the software. There is also the option of creating a private repository if you are unsure if there may be a good reason why the original upstream does not exits any more.

    And as you need the original state of the repository, you can take the first commit in your fork, before your colleague started working on it.

    So what you want to do:

    1. Create a new repository.
    2. Commit the state of the software before you started working on it.
    3. Commit any changes (you can even choose a new branching scheme now)

    Again, be mindful of the original license if this is not your own code!

    If your are only working on a fork of a fork which has no upstream anymore but you want to commit to the original upstream that does still exist: Simply fork from the very original, commit your code and pr.