iPhone Developer iPhone Developer - 6 months ago 25
Git Question

Git pull a branch from a different repository

I've few files in my current repository. I want to merge a remote branch from a different repository.

  1. Pull and merge a branch from
    (branch loader)

  2. Then pull and merge a branch from
    (branch login)

Is it possible or what's the workaround? I wanna keep adding code to my current branch from different remote branches.


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