GitHub: Forking a Branch
Here’s the situation:
I am contributing to this repo: https://github.com/HabitRPG/habitrpg
- git clone command is not working?
- TeamCity: Subversion VCS root with GitHub externals
- How to pull a pull request quickly locally
- git add/commit deleting and not just ignoring .gitignore ignored file
- Build Github Package as Maven using Jitpack
- How to change a github repo's directory to somewhere else?
Here is my local repo: https://github.com/nafoster/habitrpg
I want to take the ja_trans branch from this person’s repo: https://github.com/Fandekasp/habitrpg
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?
2 Solutions collect form web for “GitHub: Forking a Branch”
Fetch the branch you want.
git remote add fandekasp https://github.com/Fandekasp/habitrpg 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: https://help.github.com/articles/syncing-a-fork
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).