GitHub: Forking a Branch

Here’s the situation:

I am contributing to this repo:

Here is my local repo:

I want to take the ja_trans branch from this person’s repo:

and fork it into my own so later, I can pull request it into the original repo.

I’m still relatively new at GitHub/Git. How would I do this?

  • Git: why necessary to update master first?
  • Adding a collaborator to my free GitHub account?
  • How to fast track branch after pull request in Github
  • Start with a clean slate
  • Git: delete a single remote revision
  • Best way to share Github pull request templates between projects?
  • About using GitHub: repo for every module?
  • Git submodule pull request work flow
  • 2 Solutions collect form web for “GitHub: Forking a Branch”

    Fetch the branch you want.

    git remote add fandekasp
    git fetch fandekasp
    git checkout ja_trans

    Maybe commit some stuff, then push it to your own repo, assuming it’s called origin:

    git push origin ja_trans

    Now set up a PR.

    First of all, you need to set up fork syncing. There is some documentation here:

    You should keep your fork up to date when submitting pull requests, in order to make it easier to merge your changes.

    After fetching from upstream, you should have all of the remote branches in your local repo. You can then create a new local branch from the remote branch:

    # update upstream
    $ git fetch upstream
    # create local 'ja_trans' branch from upstream
    $ git branch --no-track ja_trans upstream/ja_trans
    # switch to 'ja_trans'
    $ git checkout ja_trans
    # push your 'ja_trans' branch to the fork
    $ git push -u origin ja_trans

    After you are happy with your changes you can push them to your fork and submit the pull request from there.

    If you want to keep the branch up to date with the upstream branch, you can follow the instruction in the “syncing a fork” page. Just replace upstream/master with the branch from which you want to pull the changes (‘ja_trans’ in this example).

    Git Baby is a git and github fan, let's start git clone.