{"id":41,"date":"2016-07-11T16:27:00","date_gmt":"2016-07-11T16:27:00","guid":{"rendered":"\/colin\/morethanfour\/post\/Git-how-to-create-a-merge-conflict-all-on-your-own"},"modified":"2016-07-11T16:27:00","modified_gmt":"2016-07-11T16:27:00","slug":"git-how-to-create-a-merge-conflict-all-on-your-own","status":"publish","type":"post","link":"https:\/\/spacefold.com\/colin\/morethanfour\/2016\/07\/11\/git-how-to-create-a-merge-conflict-all-on-your-own\/","title":{"rendered":"Git: how to create a merge conflict all on your own"},"content":{"rendered":"<p>I had some doubts that I was seeing all the changes from all developers, so I did some testing.<\/p>\n<p>(I ran a <strong>git log<\/strong> command after each step to see what changes would show up.)<\/p>\n<p><strong>Step 1<\/strong>: Add a new file, and commit locally:<\/p>\n<div id=\"codeSnippetWrapper\">\n<pre id=\"codeSnippet\" style=\"border-top-style: none; font-size: 8pt; overflow: visible; border-left-style: none; font-family: 'Courier New', courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">Mon Jul 11 21:05:41 2016 - Colin Nicholls : (Testing) Added a file locally<br>A       misc_scripts\/Testing_git_log.txt<br><\/pre>\n<\/div>\n<p><strong> <\/strong><\/p>\n<p><strong>Step 2<\/strong>: Pull from remote to refresh locally<\/p>\n<p><strong>Step 3<\/strong>: Push my local changes to the remote (origin).<\/p>\n<p><strong>Step 4<\/strong>: Edit the file, and commit. I misunderstood the use of the <strong>[x] Amend Last commit<\/strong> checkbox&#8230;<\/p>\n<div id=\"codeSnippetWrapper\">\n<pre id=\"codeSnippet\" style=\"border-top-style: none; font-size: 8pt; overflow: visible; border-left-style: none; font-family: 'Courier New', courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">Mon Jul 11 21:10:28 2016 - Colin Nicholls : (Testing) Editing a file locally<br>A       misc_scripts\/Testing_git_log.txt<\/pre>\n<p><\/div>\n<p>Note that the time-stamp has changed, and the comment text, but it is the same &#8220;Add&#8221; operation.<\/p>\n<p><strong>Step 5<\/strong>: Edit the file again, and commit. (This time, I did not use the <strong>[  ] Amend last commit<\/strong>, and I commented thusly:<\/p>\n<div id=\"codeSnippetWrapper\">\n<pre id=\"codeSnippet\" style=\"border-top-style: none; font-size: 8pt; overflow: visible; border-left-style: none; font-family: 'Courier New', courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">Mon Jul 11 21:10:28 2016 - Colin Nicholls : (Testing) Editing a file locally<br>A       misc_scripts\/Testing_git_log.txt<br> <br>Mon Jul 11 21:12:43 2016 - Colin Nicholls : (testing) [ ] Amend last commit (did not check)<br>M       misc_scripts\/Testing_git_log.txt<\/pre>\n<p><\/div>\n<p><strong>Step 6<\/strong>: Do a push to remote repository:<\/p>\n<div id=\"codeSnippetWrapper\">\n<pre id=\"codeSnippet\" style=\"border-top-style: none; font-size: 8pt; overflow: visible; border-left-style: none; font-family: 'Courier New', courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">git.exe push --progress <span style=\"color: #006080\">\"origin\"<\/span> master:master<br> <br>To https:\/\/github.abacab.com\/zyxx\/zyxx-db.git<br>! [rejected] master -&gt; master (non-fast-forward)<br>error: failed to push some refs to <span style=\"color: #006080\">'https:\/\/github.abacab.com\/zyxx\/zyxx-db.git'<\/span><br>hint: Updates were rejected because the tip of your current branch is behind<br>hint: its remote counterpart. Integrate the remote changes (e.g.<br>hint: <span style=\"color: #006080\">'git pull ...'<\/span>) before pushing again.<br>hint: See the <span style=\"color: #006080\">'Note about fast-forwards'<\/span> <span style=\"color: #0000ff\">in<\/span> <span style=\"color: #006080\">'git push --help'<\/span> <span style=\"color: #0000ff\">for<\/span> details.<br>git did not exit cleanly (exit code 1) (1981 ms @ 7\/11\/2016 13:14:39)<br><\/pre>\n<p><\/div>\n<p>OK, I don&#8217;t understand why &#8220;the tip of my current branch is behind its remote counterpart&#8221;, but it is telling me I should do another pull before pushing, so:<\/p>\n<p><strong>Step 7<\/strong>: Pull from the remote to update locally:<\/p>\n<div id=\"codeSnippetWrapper\">\n<pre id=\"codeSnippet\" style=\"border-top-style: none; font-size: 8pt; overflow: visible; border-left-style: none; font-family: 'Courier New', courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">git.exe pull --progress --no-rebase -v <span style=\"color: #006080\">\"origin\"<\/span><br> <br>From https:\/\/github.abacab.com\/zyxx\/zyxx-db<br>= [up to date] master -&gt; origin\/master<br>= [up to date] cmp13_convert -&gt; origin\/cmp13_convert<br>= [up to date] dev_2015_02_A -&gt; origin\/dev_2015_02_A<br>= [up to date] dyson -&gt; origin\/dyson<br>= [up to date] edison -&gt; origin\/edison<br>= [up to date] fermi -&gt; origin\/fermi<br>= [up to date] gauss -&gt; origin\/gauss<br>= [up to date] grendel -&gt; origin\/grendel<br>= [up to date] hubble -&gt; origin\/hubble<br>= [up to date] prod_2015_04 -&gt; origin\/prod_2015_04<br>Auto-merging misc_scripts\/Testing_git_log.txt<br>CONFLICT (add\/add): Merge conflict <span style=\"color: #0000ff\">in<\/span> misc_scripts\/Testing_git_log.txt<br>Automatic merge failed; fix conflicts and then commit the result.<br>git did not exit cleanly (exit code 1) (2231 ms @ 7\/11\/2016 13:15:42)<\/pre>\n<p><\/div>\n<p>Now I&#8217;m in conflict with myself!?<\/p>\n<\/p>\n<p><strong>Step 8<\/strong>: At this point, I resolved the conflict by selecting &#8220;mine&#8221; over &#8220;theirs&#8221;, and did another local commit. This time I got a special &#8220;merge commit&#8221; dialog that didn&#8217;t show any specific changed files, but clearly wanted to do something.<\/p>\n<p>So what does the log say at this point?<\/p>\n<div id=\"codeSnippetWrapper\">\n<pre id=\"codeSnippet\" style=\"border-top-style: none; font-size: 8pt; overflow: visible; border-left-style: none; font-family: 'Courier New', courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">Mon Jul 11 21:05:41 2016 - Colin Nicholls : (Testing) Added a file locally<br>A       misc_scripts\/Testing_git_log.txt<br> <br>Mon Jul 11 21:10:28 2016 - Colin Nicholls : (Testing) Editing a file locally<br>A       misc_scripts\/Testing_git_log.txt<br> <br>Mon Jul 11 21:12:43 2016 - Colin Nicholls : (testing) [ ] Amend last commit (did not check)<br>M       misc_scripts\/Testing_git_log.txt<br> <br>Mon Jul 11 21:22:08 2016 - Colin Nicholls : Merge branch <span style=\"color: #006080\">'master'<\/span> of https:\/\/github.abacab.com\/zyxx\/zyxx-db<\/pre>\n<p><\/div>\n<p>Interesting:<\/p>\n<ol>\n<li>The first edit operation has now returned to the log. It looks as though we have two &#8220;Add&#8221; operations.<\/li>\n<li>We get a generic &#8220;merge branch&#8221; message as the most recent log entry.<\/li>\n<li>Also, the time-stamps aren&#8217;t &#8220;local&#8221; time, at least, not my local time (it&#8217;s 13:25 PDT currently)<\/li>\n<\/ol>\n<p><strong>Step 9<\/strong>: Pull; delete test file; commit; push<\/p>\n<div id=\"codeSnippetWrapper\">\n<pre id=\"codeSnippet\" style=\"border-top-style: none; font-size: 8pt; overflow: visible; border-left-style: none; font-family: 'Courier New', courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">Mon Jul 11 21:05:41 2016 - Colin Nicholls : (Testing) Added a file locally<br>A       misc_scripts\/Testing_git_log.txt<br> <br>Mon Jul 11 21:10:28 2016 - Colin Nicholls : (Testing) Editing a file locally<br>A       misc_scripts\/Testing_git_log.txt<br> <br>Mon Jul 11 21:12:43 2016 - Colin Nicholls : (testing) [ ] Amend last commit (did not check)<br>M       misc_scripts\/Testing_git_log.txt<br> <br>Mon Jul 11 21:22:08 2016 - Colin Nicholls : Merge branch <span style=\"color: #006080\">'master'<\/span> of https:\/\/github.abacab.com\/zyxx\/zyxx-db<br>Mon Jul 11 21:35:21 2016 - Colin Nicholls : (testing) deleted file<br>D       misc_scripts\/Testing_git_log.txt<\/pre>\n<p><\/div>\n<p>This needs further testing, perhaps, but I&#8217;m going to return to billable work at this point.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I had some doubts that I was seeing all the changes from all developers, so I did some testing. (I ran a git log command after each step to see what changes would show up.) Step 1: Add a new file, and commit locally: Mon Jul 11 21:05:41 2016 &#8211; Colin Nicholls : (Testing) Added [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-41","post","type-post","status-publish","format-standard","hentry","category-source-control","post-preview"],"_links":{"self":[{"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/posts\/41","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/comments?post=41"}],"version-history":[{"count":0,"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/posts\/41\/revisions"}],"wp:attachment":[{"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/media?parent=41"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/categories?post=41"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/tags?post=41"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}