Git pull a branch from a different repository

You can add other origins for your repository using

git remote add new_origin git@theUrlToRepo

You can now start pushing/pulling and basically doing all operations on both of your remotes.

git push origin master
git push new_origin master

git pull origin master
git pull new_origin master

You just have to specify which remote you're doing your operations with and you're set.

In your specific usecase, after adding remote repos and naming them, you'd do something like the following to merge remote branches into your local workspace.

git merge origin/loader
git merge new_origin/login

You can also do

git pull <git_pull_url> <branch> --allow-unrelated-histories

You can just

git pull url branch

it works


do this from your original repo that you want to merge the new code into:

for me i just created a new branch with the same name first:

git checkout -b my_new_branch

then i added the other origin:

git remote add new_origin http://someRepo.git

then i simply pulled the branch from new_origin into my current repo:

git pull new_origin my_new_branch 

the git pull command should do a fetch and merge for you.

Tags:

Git

Git Pull