How to merge from a second remote?

How to merge from a second remote?

I've got two remotes. One is identical to my local and the other is slightly different (from a different project). How do I cherry-pick commits from the second remote and merge them into my project. So far I have trashed my local about 20 times trying to do this.

Also if there is a conflict how do I solve it?

9 answers

So, is this not possible in Sourcetree then? If not what is the point of multiple remotes?

[Assuming your clone has both remotes connected. If not, right click on "Remotes" and add the second one.]

Just above the top-left corner of the commit list, there is a drop-down (All Branches / Current Branch) and a checkbox (Show Remote Branches). Set these to All branches and on.

Do a Fetch, make sure the Fetch from all remotes option is on.

Now you should see the remote branches from both repos and you can cherry-pick merge from any of them.

For resolving conflicts, you need to have a diff program and set it up in Tools/options.

Thanks for the answer. Had no problem already with steps 1,2,& 3.

Please explain step 4 (cherry pick) as I can't figure out how to do this.

Also, when you say a diff program what do you mean? Up until now I've always edited my code in a text editor (Crimson).

Cherry pick:

  1. check out the branch you want to cherry pick to
  2. right click on the commit you want to cherry pick and select cherry pick

diff program: a file comparison tool that can do merges. (You will need something that can do 3-way merge.)

Any particular program you recommend for doing the merges?

I like http://kdiff3.sourceforge.net/ , it is simple, fast and free. (In SourceTree, go to Tools\Options\Diff to set up the integration.)

Ok, I've got both remotes loaded. I fetch from remote one (copy of origin) and it says 5 commits behind. In the Log/history at the top it says "uncommitted changes". How do I commit those changes? Because while they are there I can't do anything. Tried the commit button but it doesn't commit them.

Try refreshing the view (F5) in the commit dialog. It has to show all uncommitted changes after this. You can select them to be committed or discard them as you see fit.

Still not getting anywhere fast with cherry pick. Now I get this.

 

cherry-pick.jpg

"Nothing to commit" => Looks like the change you were trying to cherry pick is already included in the target branch

How do I select the target branch. Maybe I am cherry picking back to the same branch.

 

Anyway thanks for the help so far.

In your screenshot above there is a part of the window that you minimised to non-existence. It should be between the bookmarks and the history part. Make it appear. Here you will see the local branches and the remote branches. The one which is bold is the current branch. You can switch to another by double-clicking the branch name.

Here's what it looks like without the cherry pick window. So where is the minimised window?

UNTITLED.jpg

It is the grey bar in the middle that says File Status, Branches, Remotes. Your current branch is master.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Oct 23, 2018 in Sourcetree

Tip from the team: configure your repos for hosting goodness!

Supported Platforms macOS Windows We recently introduced support for additional hosting services such as GitHub Enterprise, GitLab (Cloud, Community Edition, Enterprise Edition), and...

718 views 3 2
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you