Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools

selfish merging

I could not find a good answer for this on the internet it's the extra credit of the Merging stage of the git basics course.

How to I ignore conflicts and only apply my changes when merging?

2 Answers

Brendan Moran
Brendan Moran
14,052 Points

If you want to prioritize the changes in the branch that you are merging in (say you performed some kind of overhaul, per the example given in extra credit), you would use

git merge -Xtheirs <branch_name>

If you wanted to prioritize changes in the the dev or master branch (or whatever branch is hosting the merger), you would use

git merge -Xours <branch_name>

https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging

+1 for the reference to the Git documentation, just wanted to add a reference to the "Git book" from the same website: https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging (scroll down to the "Ours or Theirs Preference" section.)