Technical contributor onboarding/Resolve merge conflict
Introduction
editWe will try to resolve the conflict for patch gerrit:591060. You can see that the patch has a merge conflict in two places, at the top of the page, and at the bottom of the page.
Pull
editPull the latest commit from the TemplateWizard
repository.
cd mediawiki/extensions/TemplateWizard
git checkout master
git pull origin master
Fetch
editGet the patch from Gerrit.
git review -d 591060
Rebase
editRebase the patch on top of the master
branch. Git will let you know that there's a merge conflict.
git rebase master
First, rewinding head to replay your work on top of it...
Applying: Upgraded WebdriverIO from v4 to v5
Using index info to reconstruct a base tree...
M package-lock.json
M package.json
Falling back to patching base and 3-way merge...
Auto-merging package.json
CONFLICT (content): Merge conflict in package.json
Auto-merging package-lock.json
CONFLICT (content): Merge conflict in package-lock.json
error: Failed to merge in the changes.
Patch failed at 0001 Upgraded WebdriverIO from v4 to v5
hint: Use 'git am --show-current-patch' to see the failed patch
Resolve all conflicts manually, mark them as resolved with
"git add/rm <conflicted_files>", then run "git rebase --continue".
You can instead skip this commit: run "git rebase --skip".
To abort and get back to the state before "git rebase", run "git rebase --abort".
The output from git status
is clearer than that from normal Git, so prefer that instead.
git status
rebase in progress; onto 049a0fd
You are currently rebasing branch 'review/vidhi_mody/test' on '049a0fd'.
(fix conflicts and then run "git rebase --continue")
(use "git rebase --skip" to skip this patch)
(use "git rebase --abort" to check out the original branch)
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: tests/selenium/.eslintrc.json
modified: tests/selenium/specs/TemplateWizard.js
modified: tests/selenium/wdio.conf.js
Unmerged paths:
(use "git reset HEAD <file>..." to unstage)
(use "git add <file>..." to mark resolution)
both modified: package-lock.json
both modified: package.json
Conflict
editThis is the important part of the output. The rest can be ignored for now.
both modified: package-lock.json
both modified: package.json
Both your patch
and master
branches have modified files:
package-lock.json
*package.json
.
Resolve package.json
editWe will first resolve the conflict in package.json
:
cat package.json
{
"private": true,
"scripts": {
"selenium-daily": "npm run selenium-test",
"selenium-test": "wdio tests/selenium/wdio.conf.js",
"test": "grunt test"
},
"devDependencies": {
<<<<<<< HEAD
"eslint-config-wikimedia": "0.15.3",
"grunt": "1.1.0",
"grunt-banana-checker": "0.9.0",
"grunt-eslint": "22.0.0",
"grunt-stylelint": "0.15.0",
"stylelint-config-wikimedia": "0.10.1",
"wdio-mediawiki": "0.5.0",
"wdio-mocha-framework": "0.6.4",
"wdio-spec-reporter": "0.1.5",
"webdriverio": "4.14.4"
=======
"@wdio/cli": "5.22.4",
"@wdio/junit-reporter": "5.22.4",
"@wdio/local-runner": "5.22.4",
"@wdio/mocha-framework": "5.18.7",
"@wdio/spec-reporter": "5.22.4",
"@wdio/sync": "5.18.7",
"eslint-config-wikimedia": "0.15.0",
"grunt": "1.1.0",
"grunt-banana-checker": "0.9.0",
"grunt-eslint": "22.0.0",
"grunt-stylelint": "0.14.0",
"stylelint-config-wikimedia": "0.9.0",
"wdio-mediawiki": "1.0.0",
"webdriverio": "5.22.4"
>>>>>>> Upgraded WebdriverIO from v4 to v5
}
}
This is not very readable and probably looks more scary than it is.
- The code portion between
<<<<<<< HEAD
and=======
is in themaster
branch. - The code portion between
=======
and>>>>>>> Upgraded WebdriverIO from v4 to v5
is in your patch.
Note that a few packages are updated in master.
eslint-config-wikimedia
from 0.15.0 to 0.15grunt-stylelint
from 0.14.0 to 0.15.0stylelint-config-wikimedia
from 0.9.0 to 0.10.1
Edit the file so that it looks like this:
cat package.json
{
"private": true,
"scripts": {
"selenium-daily": "npm run selenium-test",
"selenium-test": "wdio tests/selenium/wdio.conf.js",
"test": "grunt test"
},
"devDependencies": {
"@wdio/cli": "5.22.4",
"@wdio/junit-reporter": "5.22.4",
"@wdio/local-runner": "5.22.4",
"@wdio/mocha-framework": "5.18.7",
"@wdio/spec-reporter": "5.22.4",
"@wdio/sync": "5.18.7",
"eslint-config-wikimedia": "0.15.3",
"grunt": "1.1.0",
"grunt-banana-checker": "0.9.0",
"grunt-eslint": "22.0.0",
"grunt-stylelint": "0.15.0",
"stylelint-config-wikimedia": "0.10.1",
"wdio-mediawiki": "1.0.0",
"webdriverio": "5.22.4"
}
}
Finally, use git add
to let Git know that you've resolved the conflict.
git add package.json
Resolve package-lock.json
editgit status
will now say there's only one file left to resolve.
git status
...
both modified: package-lock.json
We will now resolve the conflict in package-lock.json
. It is automatically generated so you should not edit it manually.
Delete the file and recreate it with npm install
:
rm package-lock.json
npm install
Next, use git add
to let Git know that you've resolved the conflict:
git add package-lock.json
Check using git status
editgit status
will now say there are no conflicts left:
git status
rebase in progress; onto 049a0fd
You are currently rebasing branch 'review/vidhi_mody/test' on '049a0fd'.
(all conflicts fixed: run "git rebase --continue")
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: package-lock.json
modified: package.json
modified: tests/selenium/.eslintrc.json
modified: tests/selenium/specs/TemplateWizard.js
modified: tests/selenium/wdio.conf.js
Rebase
editContinue the rebase using git rebase --continue
:
git rebase --continue
Applying: Upgraded WebdriverIO from v4 to v5
Using git status
now shows:
git status
On branch review/vidhi_mody/test
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
Use your Git diff tool to check the changes in the last patch, and make sure everything looks good.
Push to Gerrit
editFinally, use git review
to push the changes to Gerrit.
git review