Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,552,839
Community Members
 
Community Events
184
Community Groups

Visually merging individual changes from diff between branches

Quite often it happens that some things were developed in a feature branch where I want to split off some of them into another branch that I can submit for a PR, while maintaining the rest in the feature branch for further development as they're not ready. In general, they cannot be separated by commits so I cannot cherry pick.

Say I branch off master and want to put some things into this new branch from my feature branch. I do "Diff Against Current" to see my changes, and then want to select from them (not individual commits, but the overall changes I see in this diff view). How then can I select individual changes to copy from the new branch? The "Reverse hunk" choices in the right pane when a file is selected don't work because the action happens in the opposite direction regardless of which is the selected branch. I can't even generally open from the UI the corresponding file from either branch to copy-paste manually from one to the other, because a lot of the time "Open Current Version" and "Open Selected Version" open the same version (what's up with that??)

I've seen this article, http://jasonrudolph.com/blog/2009/02/25/git-tip-how-to-merge-specific-files-from-another-branch/ but I don't see how I can do this visually within Sourcetree (how would I add a custom action for this?), and moreover, it limits me to doing whole files. How would I make it so I can visually merge between the file from two branches starting with Sourcetree and say using an external merge tool?

2 answers

1 accepted

0 votes
Answer accepted
Ana Retamal
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Nov 10, 2017

Hi Borislav, I'm afraid you can not do this in Sourcetree, you can only do whole files. If you'd like, you can submit this as a Feature request in our issue tracker.

Best regards!

Ana

I would probably suggest cloning the repo twice, into two separate folders, possibly with the names of the two pranches you are interested in.   In each distinct folder, checkout the branch of interest.  Then use an external compare-and-mege tool (e.g., meld, vimdiff, WinMerge, BeyondCompare, etc.) to compare two files of interest from the two folders, and copy into the tar get file the code for the changes you are wanting to get.  Repeat this step for each two files where, atr least one has code you are interested in capturing.  This will allow you to capture all the code of interst and include it within one folder.  Compile, pull changes from the remote instance of that branch (if two or more people are working in that branch, merge in changes from master, recompile, test, push out your local changes to that branch, and blow away the other folder.  Done.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events