Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I merge only non-conflicting changes in Git?

How can I simply (e.g. in one command?) merge in Git, keeping the state of conflicting files as in the current branch and without specifying each file individually as in theirs/ours options?

git checkout master
git merge stable --some-option-to-keep-files-?
like image 484
Paul Avatar asked Sep 24 '12 20:09

Paul


People also ask

How do you combine codes without conflict?

In order to avoid a merge conflict, all changes must be on different lines, or in different files, which makes the merge simple for computers to resolve. In other words, if a change introduces any ambiguity even at a single line of code an automatic merging is canceled and the whole process must be finished manually.

Can I merge specific commit?

Merging a specific commit from one branch to another is pretty easy: use the git cherry-pick command. The syntax is: git cherry-pick <commit hash> . Here is how you go about doing it. First make a note of the commit hash using the git reflog or git log command.


1 Answers

The merge strategy has an "ours" option which is what you want

git merge -s recursive -X ours remote/branch

As the manpage stresses out, this is NOT git merge -s ours.

like image 168
sylvain.joyeux Avatar answered Sep 30 '22 03:09

sylvain.joyeux