Search code examples
gitgithubfork

Git_GitHub Fork only master branch of a repo


I'm working on this project. As it is fairly big, the upstream repo has quite a few branches, but what I really care about is the master branch. I need to fork the repo and create a new branch, starting from actual status of master. I don't care about all otheres "work in progress" branches, I will have my own branches.

Is there a way to fork the repo, but only the master branch, to keep things clean from my perspective. Would this cause problems if later I try to issue a merge request?

Thanks, Andrea


Solution

  • Regarding GitHub, this is now (July 2022, 2 years later) possible.

    You can now fork a repo and copy only the default branch

    Previously, when creating a fork all branches from the parent repository were copied to the new fork repository.

    There are several scenarios where this is unneeded, such as contributing to open-source projects.
    When all branches are copied, it could result in slow repo cloning and unnecessary disk usage.

    With this new feature, only the default branch is copied; no other branches or tags.
    This may result in faster clones because only reachable objects will be pulled down.

    New fork page with ability to copy only the default branch

    If you want to copy additional branches from the parent repository, you can do so from the Branches page.