Merge Changes with a Remote Branch

I started to learn Git and I am stuck in one problem.

Let's say that there is one master repository and two forks.

master

-> fork1 -> my local clone

-> fork2

I work on one fork and I can pull the changes from the main repository and merge them with my own. Now let's say that some changes are made in one branch in the second fork. How can I pull them out and join my repo?

fork2 -> merge with my local clone -> push to fork1

Also, can I merge a specific commit (by commit hashing) from the remote branch in the second fork and how?

Thank you for your responses.

+5
source share
1 answer

Define fork2 as a remote repo in your fork1

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

then select the changes from fork2

git fetch fork2

fork2.

git pull fork2 <branch name>

- . fork1, .

git checkout --track -b branch_fork2 fork2/branch2

branch_fork2.

, fork2.

git checkout feature_1

git merge branch_fork2

, .

+7