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,459,097
Community Members
 
Community Events
176
Community Groups

How to apply a patch - copy only some lines from experimental to suggestFix branch?(Git)

Edited

So I have 3 branches: master, suggestFix and experimental. suggestFix points at the same place as master because I want to use master as a starting point to create pull request on GitHub. experimental has different commits, and I want to move to suggestFix branch only some lines of code from experimental.

I'll provide a concrete example. Here's final file on experimental branch:

HYkRMKb

And here are master and suggestFix branches:

cKauvoy

I want my suggestFix branch to look like this after I do whatever is needed with git tools:

zU6zz

I understand that I will need to review every single line of every single file and either accept or reject edits of lines or how they are also called hunks of code. That's what I want. I use a mix of Atlassian Sourcetree and MINGW64. I managed to start some kind of diff on Sourcetree:

qWueEBut it's not what I want. If I press on reverse hunk button, it removes all changes in experimental. I don't want to edit experimental at all. All changes should be made in suggestFix as if I edited master and got from master to suggestFix by inserting and removing lines in one commit.

Here's a GitHub repository with that specific example:
https://github.com/KulaGGin/GitPatch

Please help 2xA3vXo. It's the second day I'm trying to achieve this.

1 answer

Hi @Sergei Kulagin,

Welcome to the Atlassian Community.

What you did in Sourcetree was just a diff between your current workspace and the branch you selected, and the output Window on the right shows that diff. Reverse hunk just means that you want to undo that commit.

What you are looking for is what is called cherry-pick, which allows you to pick specific commits from one branch when merging (this is all from the command line, it is not available in Sourcetree as an option). You can find more information about Git cherry-pick here, https://www.atlassian.com/git/tutorials/cherry-pick and you can find other good tutorials there too.  

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events