iPhone Developer iPhone Developer - 1 year ago 72
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.

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download