Merge changes from remote branch

git

Solution

Define your fork2 as a remote repo in your fork1

git remote add fork2 /path/to/fork2/repo

then fetch the changes from fork2

git fetch fork2

pull the changes from the fork2.

git pull fork2 <branch name>

A word of caution is the above command will update your current branch. So you should better use a tracking remote repo and review the changes and merge it to your branch in fork1 if you are ok with it.

git checkout --track -b branch_fork2 fork2/branch2

Review the code in your local branch named branch_fork2.

Checkout the repo where you'd like to merge your fork2 changes.

git checkout feature_1

Then merge it

git merge branch_fork2

If it results in merge conflicts, solve the merge conflicts and commit it.

Problem

I started to learn Git and I'm stuck with one problem. Let's say that there is one master repository and two forks. master -> fork1 -> my local clone -> fork2 I'm working on one fork and I can pull changes from master repository and merge them with my own. Now, let's say that some changes are made in one branch in second fork. How can I pull them and merge into my repo? fork2 -> merge with my local clone -> push to fork1 Also, can I merge particular commit (by commit hash) from remote branch in second fork and how? Thanks for your answers.

Original source