Thicket data repository for the EEG
at main 2.4 kB view raw
1{ 2 "id": "https://www.tunbury.org/2025/07/10/dune-unfmt", 3 "title": "dune unfmt", 4 "link": "https://www.tunbury.org/2025/07/10/dune-unfmt/", 5 "updated": "2025-07-10T00:00:00", 6 "published": "2025-07-10T00:00:00", 7 "summary": "When working across machines, it’s easy to make changes and reconcile them using git. However, I made a mistake and inadvertently ran dune fmt and now my git diff is a total mess.", 8 "content": "<p>When working across machines, it’s easy to make changes and reconcile them using git. However, I made a mistake and inadvertently ran <code>dune fmt</code> and now my <code>git diff</code> is a total mess.</p>\n\n<p>My thought, to get myself out of this situation, is to go back to the previous commit and create a new branch with no changes other than a <code>dune fmt</code>. I can then cherry-pick my latest work on to that branch which should then give me a clean diff.</p>\n\n<div><div><pre><code>git commit <span>-am</span> <span>'inadvertent reformatted version'</span>\n</code></pre></div></div>\n\n<p>Run <code>git log</code> to find the commit that was just made and the previous one.</p>\n\n<p>Checkout the previous commit and make a new branch, in my case called <code>pre-fmt</code>.</p>\n\n<div><div><pre><code>git checkout &lt;previous commit&gt;\ngit switch <span>-c</span> pre-fmt\n</code></pre></div></div>\n\n<p>Format the code in this branch and commit that version.</p>\n\n<div><div><pre><code>dune <span>fmt\n</span>git commit <span>-am</span> <span>'dune fmt'</span>\n</code></pre></div></div>\n\n<p>Now cherry-pick the original commit.</p>\n\n<div><div><pre><code>git cherry-pick &lt;latest commit&gt;\n</code></pre></div></div>\n\n<p>The cherry-pick reports lots of merge conflicts; however, these should be trivial to resolve but it is a manual process. Once done, add the changed files and finish the cherry-pick.</p>\n\n<div><div><pre><code>git add bin/<span>*</span>.ml\ngit cherry-pick <span>--continue</span>\n</code></pre></div></div>\n\n<p><code>git diff</code> now shows just the actual changes rather than the code formatting changes. Do you have any suggestions on a better workflow?</p>", 9 "content_type": "html", 10 "author": { 11 "name": "Mark Elvers", 12 "email": "mark.elvers@tunbury.org", 13 "uri": null 14 }, 15 "categories": [ 16 "git" 17 ], 18 "source": "https://www.tunbury.org/atom.xml" 19}