Search code examples
gitgithubgit-fork

How to fork a branch and not the repository?


How can I fork a branch instead of a complete repository? I wish to copy only the branch https://github.com/COMSYS/contiki/tree/split-buffer and not the complete repository https://github.com/jenshiller/contiki. How to fork a branch in Git? won't work in my case. I don't want to clone the branch.


Solution

  • In github (and in git's mental framework) you clone and fork repositories.

    There's no way to fork a branch; that doesn't make sense. Just fork the project, and work off the branch you're interested in. You don't lose anything by doing so.

    "Working off a branch" usually means you

    1. clone a repository (e.g. git clone http://repository), then
    2. check out the branch you're interested in (git checkout awesome-branchname),
    3. and create a new branch based of that (git checkout -b new-even-more-awesome-branch-name)