Most of the time, git
will easily and correctly combine the
simultaneous work of two or more developers. However, if two
developers have both edited the same lines or nearby lines of a single
file, git
will err on the side of caution and require that a
developer who is familiar with the specific file and the recent
changes to manually resolve this merge conflict.
For simple merge conflicts, it is often possible to resolve the merge conflict using the GitHub web GUI for file editing. But sometimes, it is necessary to use the git command line and an editor on your local machine.
Composer PHP Package Manager Files
As a specific example, let’s resolve a merge conflict with the
composer.lock
file:
-
Make sure master is up-to-date:
git checkout master git pull
-
Checkout your branch:
git checkout <YOUR_SPECIFIC_BRANCH>
-
Replace the
composer.json
andcomposer.lock
file in this branch with that of master:git checkout master -- site/composer.lock site/composer.json
-
Commit changed files:
git add . git commit -m "wip"
-
Merge master:
git merge master
-
Then re-introduce your dependency:
pushd site composer require <YOUR_NEEDED_COMPOSER_PACKAGE> popd
-
Commit the updated
composer.json
andcomposer.lock
files.