Conflicts can occur when modified file(s) within your site's codebase do not align with changes made to the same file(s) in the site's upstream.
When a merge isn’t resolved automatically, Git leaves the index and the working tree in a special state that gives you all the information you need to help resolve the merge.
The fastest resolution for conflicts when updating is often to use the
-Xtheirs flag. This will attempt to automatically resolve the conflicts with a preference for upstream changes.
This is safe to run if you don't have your own changes in any of the conflicting files (for example problems with
git pull -Xtheirs https://github.com/pantheon-systems/drops-7.git master # resolve conflicts git push origin master
git pull -Xtheirs https://github.com/pantheon-systems/WordPress.git master # resolve conflicts git push origin master
git pull -Xtheirs https://github.com/pantheon-systems/wordpress-network.git master # resolve conflicts git push origin master
Double-check the files before going forward to make sure no bugs were introduced.
-Xtheirsflag will drop your changes if you modify core CMS files. You should manually resolve conflicts in this scenario.
Review WordPress and Drupal Core Updates for more details on core updates.
Run the following command in Terminus to retrieve your Upstream URL:
terminus site:info <site> --field=upstream
Steps to resolve merge conflicts vary by the type of conflict. Refer to the sections below for more information on resolving delete/modify conflicts, content conflicts, and Multidev conflicts.
A delete/modify conflict occurs when one commit deletes a file and another modifies it. Follow the steps below to resolve such a conflict.
Identify the file that is generating a delete error.
For example, the Git log may contain an entry similar to the following:
CONFLICT (delete/modify): scripts/run-tests.sh deleted in HEAD and modified in 72faeeff1c9356221694d1351cdb2000ab3c5d1c. Version 72faeeff1c9356221694d1351cdb2000ab3c5d1c of scripts/run-tests.sh left in tree.
Navigate to your local repository > run the following Git command to get a copy of the file in conflict:
git checkout <commit ID> -- <file>
When looking for a commit ID, you can find the last instance where the missing file was in the repository.
git statusand verify that there is a new file to add to the repository:
git status On branch master Changes to be committed: (use "git reset HEAD ..." to unstage) new file: README.txt
Stage and commit:
git commit -am "verifying missing README.txt"
You will receive confirmation from Git that the file has been committed.
Run the Git push command:
git push origin master
A content conflict occurs when two commits modify the same line(s) of a file non-sequentially (without one having the other in its history). For example:
CONFLICT (content): Merge conflict in wp-admin/about.php Automatic merge failed; fix conflicts and then commit the result.
Follow the steps below to resolve this scenario.
Open the conflicting file in your text editor or IDE. Note that the conflicting lines are enclosed with
< HEADat the top, and
> <commit-id>at the bottom, with
=======delineating the two versions. Some IDEs, like Visual Studio Code for example, will highlight the conflicting section:
Edit the conflict by choosing one of the two versions of the conflicting line(s), or by editing a version containing both updates.
Remove all the delineator notes from the file.
Commit and push your changes:
git add wp-admin/about.php git commit -m "Merge conflict resolution" git push origin master
Follow the steps below to resolve a merge conflict that is preventing you from merging a Multidev environment.
Navigate to your Dev environment > set the Development Mode to Git:
Click Clone with Git to Clone the repository to your local computer:
Navigate to the repository directory, change to the
masterbranch and pull the Multidev branch to
In the example below, replace
multidevwith the Multidev environment name:
git checkout master git pull origin multidev
Resolve the conflicts using the steps above when you receive the Git notification listing the files that are in conflict.