<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Bash on Everyone Has a Story</title><link>https://bhaveshsgupta.com/tags/bash/</link><description>Recent content in Bash on Everyone Has a Story</description><generator>Hugo</generator><language>en-us</language><managingEditor>BhaveshSGupta@gmail.com (Bhavesh S. Gupta)</managingEditor><webMaster>BhaveshSGupta@gmail.com (Bhavesh S. Gupta)</webMaster><lastBuildDate>Fri, 30 Oct 2026 16:45:27 +0530</lastBuildDate><atom:link href="https://bhaveshsgupta.com/tags/bash/index.xml" rel="self" type="application/rss+xml"/><item><title>Recovering a file git never committed</title><link>https://bhaveshsgupta.com/blog/recovering-a-file-git-never-committed/</link><pubDate>Mon, 12 Oct 2026 09:00:00 +0530</pubDate><author>BhaveshSGupta@gmail.com (Bhavesh S. Gupta)</author><guid>https://bhaveshsgupta.com/blog/recovering-a-file-git-never-committed/</guid><description>&lt;p&gt;A few days ago a colleague came to me with a file that was gone. It was part of a product feature that had already been built twice, each time taking a couple of months, and nobody wanted to build it a third time.&lt;/p&gt;&#10;&lt;p&gt;The product was built with ASP.NET Web Forms and kept in git. In Web Forms each page is mainly a pair of files: an &lt;code&gt;.aspx&lt;/code&gt; file with the page&amp;rsquo;s markup, and a &lt;code&gt;.cs&lt;/code&gt; &amp;ldquo;code-behind&amp;rdquo; file with the C# that runs on the server. Visual Studio usually adds a third, generated &lt;code&gt;.designer.cs&lt;/code&gt; file. The missing file was &lt;code&gt;ImageCropping.aspx.cs&lt;/code&gt;, the code-behind for an image-cropping page in the product&amp;rsquo;s media upload section.&lt;/p&gt;&#10;&lt;p&gt;My colleague had been working on it for a while, and it had never been committed. &lt;code&gt;git log&lt;/code&gt; had nothing to show for it, and neither did the reflog.&lt;/p&gt;&#10;&lt;p&gt;We got it back anyway, because at some point they had run &lt;code&gt;git add&lt;/code&gt; on it, and git keeps what you stage.&lt;/p&gt;&#10;&lt;p&gt;In short: &lt;code&gt;git add&lt;/code&gt; writes a copy of the file into &lt;code&gt;.git/objects&lt;/code&gt; the moment you stage it. A &lt;code&gt;git reset --hard&lt;/code&gt;, for example, removes a newly added file from your working tree, but the copy stays in the object database, unreferenced, until garbage collection removes it. &lt;code&gt;git fsck --unreachable&lt;/code&gt; lists these copies. Search them for a string you know was in the file, then copy the right one out of &lt;code&gt;.git/lost-found&lt;/code&gt;.&lt;/p&gt;</description></item></channel></rss>