Git How To/Conflict resolution
From Dreamwidth Notes
Revision as of 16:00, 24 February 2016 by AzureLunaticDW (Talk | contribs)
Where sgsabbage helped kaberett through the straightforward way of manual conflict resolution
03:48 AM <kaberett> can someone talk me through the straightforward way of getting github (or git, whichever) to show me conflicts between my branch and develop? 03:49 AM <kaberett> I could ask the internet but I'm a bit wobbly so I'm asking you lot instead :-p 03:50 AM <sgsabbage> so right. I am going off a bit of memory here and may Cock It Up and get it wrong 03:50 AM <sgsabbage> I think it'll be git rather than git hub 03:50 AM <kaberett> uhuh 03:50 AM <sgsabbage> so.. go into your branch in the command line 03:50 AM <sgsabbage> git fetch dreamwidth 03:51 AM <sgsabbage> git merge dreamwidth/develop 03:51 AM <sgsabbage> and I think it'll then give you a message about merge conflicts? 03:51 AM <kaberett> yep 03:51 AM <sgsabbage> okay, has it given you the list of files? 03:51 AM <kaberett> gives me a list of files 03:51 AM <kaberett> yep 03:52 AM <sgsabbage> I don't -think- there's a way of viewing all merge conflicts, but in each file there should be a line like.. uh.. 03:52 AM <sgsabbage> <<<<<<<< HEAD 03:52 AM <kaberett> I was kinda hoping for line numbers >>; is that a magic that can happen? 03:52 AM <sgsabbage> I'm looking now because brain is not coming up with anything on the fly 03:52 AM <kaberett> aha 03:52 AM <kaberett> yes, foudn it 03:52 AM <sgsabbage> (um have you dealt with the merge conflict format before?) 03:53 AM <kaberett> okay that's not... a super intuitive format 03:53 AM <kaberett> no 03:53 AM <sgsabbage> yeaaah 03:53 AM <kaberett> but I think I see what is going on 03:53 AM <kaberett> the top lot is mine, the bottom lot is what's on develop 03:53 AM <sgsabbage> ya 03:53 AM <kaberett> I can then mix and match the two as appropriate 03:53 AM <sgsabbage> yup. bear in mind there may be multiple lines like that 03:53 AM <kaberett> yeah 03:54 AM <sgsabbage> when it gets to merge conflicts git kinda just throws it all in a file and goes 'YOUR PROBLEM NOW' 03:54 AM <kaberett> so I've actually got an 8-line block that's doing this in the file I'm looking at 03:54 AM <kaberett> one of the other files is going to be worse, it's editing two (much longer) blocks instead 03:54 AM <kaberett> but OH WELL 03:54 AM <sgsabbage> :/ 03:54 AM <sgsabbage> so, basically, to resolve (because git doesn't tell you when you've resolved a merge conflict hahah) 03:55 AM <sgsabbage> when you've finished getting the file to where you want it (obvs with === and << and >>>> lines gone) 03:55 AM <sgsabbage> just add it like you would normally 03:55 AM <sgsabbage> and then commit once all the files are right 03:55 AM <sgsabbage> I am about 60% sure there is no 'git I fixed it all make it right' 03:56 AM <sgsabbage> it's all very manual and there is probably a better way that I've completely forgotten? 03:57 AM <kaberett> heh 03:57 AM <kaberett> this is sufficient for me to be getting on with, thank you :-) 03:57 AM <sgsabbage> awesome. Shout if you need anything else! 03:58 AM <kaberett> will do! 03:59 AM <sgsabbage> oh! right, one thing that always catches me out, is when you commit, it'll have already built the commit message for you - with the names of the conflicted files in 03:59 AM <sgsabbage> and I ALWAYS go '...wait, I thought I fixed those files' before realising that what it means was 'these files were conflicted'</nowiki>