-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hi all,
Yesterday, I tried to commit a patch to the QA_3_3 branch and then merge it with master.
Everything went well until I had to merge my changes in the QA_3_3 branch to master. This is what I did :
git pull (to sync with current changes in git) git checkout QA_3_3 (made changes to main.php and ChangeLog) git commit -a -m "message"
so far no problems, but then
git checkout master git merge QA_3_3
and then I got this :
$ git merge QA_3_3 Auto-merging ChangeLog CONFLICT (content): Merge conflict in ChangeLog Auto-merging Documentation.html Auto-merging libraries/config.default.php Auto-merging main.php Auto-merging tbl_change.php CONFLICT (content): Merge conflict in tbl_change.php Automatic merge failed; fix conflicts and then commit the result.
I understand the automerge of Documentation.html and libraries/config.default.php. They are probably different between branches. I understand why merging ChangeLog had difficulties, because I changed something there. I can imagine why main.php (the file I changed) merged without problem, probably because that file was previously unchanged, so the merge was no problem. But what I don't understand is why the tbl_change.php caused problems. I didn't touch that file, so as far as I'm concerned, that file should have been correctly merged the previous time (commit before me).
After manualy changing the tbl_change.php and ChangeLog file, I did this :
git add ChangeLog git add tbl_change.php
(because git status instructed me to)
and then
git commit git push
This resulted in these two commits :
Changed link to git repository on main page Merge branch 'QA_3_3'
It then turned out I forgot to solve two conflicts in tbl_change.php (indicated by >>>>>> HEAD and <<<<<< QA_3_3). I changed this file and commited again :
fix mistake in merge Merge branch 'master' of ssh://phpmyadmin.git.sourcefor...
(the last commit happened automaticaly when I did a git pull, before git push, because Marc had pushed a commit in the meanwhile)
So, I think everything in git is as it should be now. But I guess I made some mistakes, or there must be a way to avoid these kind of problems. (4 commits to change 2 lines of code seems a bit too much. ;) ) Everything went well until the merge part, so I wonder how you guys do it. Is it possible to only merge the changes in the last commit, and ignore all other files?
Thanks for the help.
Kind regards,
Dieter
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hi
Dne Thu, 18 Mar 2010 10:02:05 +0100 Dieter Adriaenssens dieter.adriaenssens@gmail.com napsal(a):
$ git merge QA_3_3 Auto-merging ChangeLog CONFLICT (content): Merge conflict in ChangeLog Auto-merging Documentation.html Auto-merging libraries/config.default.php Auto-merging main.php Auto-merging tbl_change.php CONFLICT (content): Merge conflict in tbl_change.php Automatic merge failed; fix conflicts and then commit the result.
I understand the automerge of Documentation.html and libraries/config.default.php. They are probably different between branches. I understand why merging ChangeLog had difficulties, because I changed something there. I can imagine why main.php (the file I changed) merged without problem, probably because that file was previously unchanged, so the merge was no problem. But what I don't understand is why the tbl_change.php caused problems. I didn't touch that file, so as far as I'm concerned, that file should have been correctly merged the previous time (commit before me).
Well the problem is that there was no merge for some changes and both branches had these changes applied separately (and by different patch because of different context) and in this case it is hard to tell which one if correct and it causes conflict (in this case it was most likely because of commits 8779405 and f0672d8).
After manualy changing the tbl_change.php and ChangeLog file, I did this :
git add ChangeLog git add tbl_change.php
(because git status instructed me to)
Well you should do this after resolving conflicts,
and then
git commit git push
This resulted in these two commits :
Changed link to git repository on main page Merge branch 'QA_3_3'
It then turned out I forgot to solve two conflicts in tbl_change.php (indicated by >>>>>> HEAD and <<<<<< QA_3_3). I changed this file and commited again :
fix mistake in merge Merge branch 'master' of ssh://phpmyadmin.git.sourcefor...
Because you seem to noticed this before pushing the changes, you could have done git commit --ammend, what folds in changes into last commit.
(the last commit happened automaticaly when I did a git pull, before git push, because Marc had pushed a commit in the meanwhile)
Yes this is the reason for merge commit (you could have done git pull - --rebase to avoid this merge commit because you did not publish your changes so far).
I hope my answers clarify the situation at least a bit :-).
- -- Michal Čihař | http://cihar.com | http://blog.cihar.com
Michal Čihař a écrit :
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hi
Dne Thu, 18 Mar 2010 10:02:05 +0100 Dieter Adriaenssens dieter.adriaenssens@gmail.com napsal(a):
$ git merge QA_3_3 Auto-merging ChangeLog CONFLICT (content): Merge conflict in ChangeLog Auto-merging Documentation.html Auto-merging libraries/config.default.php Auto-merging main.php Auto-merging tbl_change.php CONFLICT (content): Merge conflict in tbl_change.php Automatic merge failed; fix conflicts and then commit the result.
(...) Thanks Michal for the explanation. I practiced a bit. When trying a merge (I had changed just one file), I got conflict on ChangeLog.
In the ChangeLog there was an extra space on one line (just in QA_3_3), maybe this explains the previous messages.
Anyway I removed the extra space, committed and pushed.
Next I did one "dummy" change in just one file for QA_3_3, merged into master and did not receive any conflict, yeah!
Hi
Dne Mon, 22 Mar 2010 13:31:14 -0400 Marc Delisle marc@infomarc.info napsal(a):
Thanks Michal for the explanation. I practiced a bit. When trying a merge (I had changed just one file), I got conflict on ChangeLog.
In the ChangeLog there was an extra space on one line (just in QA_3_3), maybe this explains the previous messages.
Well this is most usual cause of merge problems - something what looks identical, but in fact is not. If there is obvious difference, it is usually quite easy to fix it.