-
-
Notifications
You must be signed in to change notification settings - Fork 812
How to handle conflicts with git
How to handle conflicts when merging something with git :
When you have a fork and you want update it because you have conflicts, it's good to know how to do it.
Don't forget to add the remote upstream before doing the following steps.
You have done a :
$ git fetch upstream
and then a :
$ git merge upstream/master
But it has failed :
error: Your local changes to the following files would be overwritten by merge: build/build.number Please, commit your changes or stash them before you can merge. Aborting
You have changed something in the file build/build.number, so you have two choices revert you change or if you want lose your change stash it.
In my case i do a simple revert :
$ git reset --hard HEAD
Now it's good :
HEAD is now at 030223c # [#21] Little issue with parent on agora category import
You can do the merge :
$ git merge upstream/master
But now you have a conflict :
Auto-merging administrator/components/com_kunenaimporter/CHANGELOG.php CONFLICT (content): Merge conflict in administrator/components/com_kunenaimporte r/CHANGELOG.php Automatic merge failed; fix conflicts and then commit the result.
Check the differences :
$ git diff
KunenaImporter 1.6.5-DEV ++<<<<<<< HEAD +19-July-2011 Xillibit +# [#21] Little issue with parent on agora category import + +18-July-2011 Xillibit +# [#21] Improve ccboard and agora support (improve cat<C3><A9>gories, messages + +17-July-2011 Xillibit +# [#21] Improve ccboard and agora support (avatar galleries import for agora) + +14-July-2011 Xillibit +# [#21] Improve ccboard and agora support (improvements on agora categories im +# [#21] Improve ccboard and agora support (improvements on messages import) ++======= + 18-July-2011 Matias + ^ [#30] Code cleanup in importer & exporter + ^ [#5] Reviewed and fixed phpBB3 support, closes #5 + + 17-July-2011 Matias
Go into eclipse/Zend Studio and edit the file to remove the conlfict. Then, when you have done you need to mark the conflicts as resolved :
$ git add -u
You can check that all is fine before commit :
$ git status
# new file: administrator/components/com_kunenaimporter/assets/ccboard-g ray.png # new file: administrator/components/com_kunenaimporter/assets/ccboard.p ng # new file: administrator/components/com_kunenaimporter/assets/discussio ns-gray.png # new file: administrator/components/com_kunenaimporter/assets/discussio ns.png # modified: administrator/components/com_kunenaimporter/assets/importer. css # new file: administrator/components/com_kunenaimporter/assets/joobb-gra y.png # new file: administrator/components/com_kunenaimporter/assets/joobb.png # new file: administrator/components/com_kunenaimporter/assets/kunena.pn g # new file: administrator/components/com_kunenaimporter/assets/ninjaboar d-gray.png # new file: administrator/components/com_kunenaimporter/assets/ninjaboar d.png # new file: administrator/components/com_kunenaimporter/assets/phpbb2-gr ay.png # new file: administrator/components/com_kunenaimporter/assets/phpbb2.pn g # new file: administrator/components/com_kunenaimporter/assets/phpbb3-gr ay.png # new file: administrator/components/com_kunenaimporter/assets/phpbb3-la rge.png # new file: administrator/components/com_kunenaimporter/assets/phpbb3.pn g # new file: administrator/components/com_kunenaimporter/assets/pnphpbb2- gray.png # new file: administrator/components/com_kunenaimporter/assets/pnphpbb2. png # new file: administrator/components/com_kunenaimporter/assets/smf2-gray .png # new file: administrator/components/com_kunenaimporter/assets/smf2.png # modified: administrator/components/com_kunenaimporter/config.xml # modified: administrator/components/com_kunenaimporter/controller.php # modified: administrator/components/com_kunenaimporter/kunenaimporter.x ml # modified: administrator/components/com_kunenaimporter/language/en-GB/e n-GB.com_kunenaimporter.ini # modified: administrator/components/com_kunenaimporter/models/export.ph p # modified: administrator/components/com_kunenaimporter/models/export_cc board.php # modified: administrator/components/com_kunenaimporter/models/export_ex ample.php # modified: administrator/components/com_kunenaimporter/models/export_ph pbb2.php # modified: administrator/components/com_kunenaimporter/models/export_ph pbb3.php # modified: administrator/components/com_kunenaimporter/models/export_sm f2.php # modified: administrator/components/com_kunenaimporter/models/import.ph p # modified: administrator/components/com_kunenaimporter/models/kunena.ph p # modified: administrator/components/com_kunenaimporter/views/default/tm pl/default.php # modified: administrator/components/com_kunenaimporter/views/default/vi ew.html.php # modified: administrator/components/com_kunenaimporter/views/import/tmp l/default.php # new file: administrator/components/com_kunenaimporter/views/start/inde x.html # new file: administrator/components/com_kunenaimporter/views/start/tmpl /default.php # new file: administrator/components/com_kunenaimporter/views/start/tmpl /index.html # new file: administrator/components/com_kunenaimporter/views/start/view .html.php # modified: administrator/components/com_kunenaimporter/views/user/tmpl/ default.php # modified: build/build.number #
No conflicts anymore. So, you can commit :
$ git commit -m "# [#74] Fix a very bad bug"
You need to do now a push on the origin
Kunena