TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Find the oldest line in your repo

63 pointsby surprisetalk4 months ago

18 comments

lb1lf4 months ago
Not on Git, but I was curious and grepped through the Siemens S7 repository I maintain at work; we&#x27;ve been using the same comment practice since forever, with the date in ISO8601 format. (Since before ISO 8601 even was a thing!)<p>Oldest I found?<p>1986-06-17: Trygve glemte å sjekke om vi deler på null. Fikset.<p>(Trygve forgot to check whether we divide by zero. Fixed.)
评论 #42883527 未加载
评论 #42882950 未加载
评论 #42882994 未加载
评论 #42883328 未加载
js24 months ago
You don&#x27;t need to blame every file[1]. Use `git rev-list` to find your oldest commit:<p><pre><code> git rev-list --reverse --date-order HEAD | head -1 # or git rev-list --reverse --author-date-order HEAD | head -1 </code></pre> To see the files in that commit:<p><pre><code> git ls-tree -lr &lt;commit-id&gt; </code></pre> To see a particular file:<p><pre><code> git show &lt;commit-id&gt;:&#x2F;path&#x2F;to&#x2F;file # or git cat-file -p &lt;commit-id&gt;:&#x2F;path&#x2F;to&#x2F;file </code></pre> [1] Caveat: I suppose this doesn&#x27;t account for files which no longer exist or that have been completely re-written.<p><a href="https:&#x2F;&#x2F;git-scm.com&#x2F;docs&#x2F;git-rev-list" rel="nofollow">https:&#x2F;&#x2F;git-scm.com&#x2F;docs&#x2F;git-rev-list</a><p><a href="https:&#x2F;&#x2F;git-scm.com&#x2F;docs&#x2F;git-ls-tree" rel="nofollow">https:&#x2F;&#x2F;git-scm.com&#x2F;docs&#x2F;git-ls-tree</a><p><a href="https:&#x2F;&#x2F;git-scm.com&#x2F;docs&#x2F;git-show" rel="nofollow">https:&#x2F;&#x2F;git-scm.com&#x2F;docs&#x2F;git-show</a><p><a href="https:&#x2F;&#x2F;git-scm.com&#x2F;docs&#x2F;git-cat-file" rel="nofollow">https:&#x2F;&#x2F;git-scm.com&#x2F;docs&#x2F;git-cat-file</a><p><a href="https:&#x2F;&#x2F;git-scm.com&#x2F;docs&#x2F;gitrevisions" rel="nofollow">https:&#x2F;&#x2F;git-scm.com&#x2F;docs&#x2F;gitrevisions</a>
评论 #42883719 未加载
评论 #42883646 未加载
skeptrune4 months ago
I like leaving something like gitlens on so I can see the super old lines ad-hoc when I naturally come across them. It&#x27;s fun to get glimpses of the past.
评论 #42882772 未加载
lutherqueen4 months ago
Similar oneliner to paste on MacOS terminal and get the eldest line for each file extension:<p>for ext in $(git ls-files | grep -vE &#x27;node_modules|\.git&#x27; | awk -F. &#x27;{if (NF&gt;1) print $NF}&#x27; | sort -u); do echo -e &quot;\n.$ext:&quot;; git ls-files | grep &quot;\.$ext$&quot; | xargs -I {} git blame -w {} 2&gt;&#x2F;dev&#x2F;null | LC_ALL=C sort -t&#x27;(&#x27; -k2 | head -n1; done
OJFord4 months ago
It&#x27;s probably almost always going to be a boring config line(s) in the initial commit?<p>A section header in a pylintrc or Cargo.toml, a Django settings.py var, etc. Or even an import&#x2F;var in a file that&#x27;s core enough to still exist, import logging and LOGGER = ... for example.
评论 #42882447 未加载
hoten4 months ago
&quot;Initial Commit&quot;, 9 years ago (transfered an at-the-time 15 year old SVN repo)<p>sigh..
评论 #42881564 未加载
评论 #42883408 未加载
verytrivial4 months ago
Our code base still has ghost comments about code being just so because the NeXT compiler won&#x27;t accept it any other way. No one has the heart to remove them.
评论 #42883378 未加载
评论 #42882802 未加载
zellyn4 months ago
In our monorepo (of 101470 Java files, according to<p><pre><code> find . -name &#x27;*.java&#x27; | wc -l </code></pre> ), I shudder to think how long that would take. For large repos, I imagine you could get quite a bit faster by only considering files created before the oldest date you&#x27;ve found so far.
kazinator4 months ago
If any of the lines form the repo&#x27;s first commit happen to be untouched, then that&#x27;s a huge short-cut: those lines are the oldest. Finding one of those lines manually is a pretty easy task. Enumerating them all accurately, less so.
JensRantil4 months ago
Not sure why all the lines of code. This is much shorter:<p><pre><code> git ls-files|xargs -n 1 git blame --date=format:%Y%m%d -f |grep -Eo &#x27;\d{8}.*&#x27; |sort -r | head -n 1 | sed &#x27;s&#x2F;^[^)]*) \t&#x2F;&#x2F;&#x27; </code></pre> (on MacOSX)
评论 #42883347 未加载
评论 #42883367 未加载
评论 #42882439 未加载
abejfehr4 months ago
doesn&#x27;t seem to work on macOS, I get:<p><pre><code> find: illegal option -- t usage: find [-H | -L | -P] [-EXdsx] [-f path] path ... [expression] find [-H | -L | -P] [-EXdsx] -f path [path ...] [expression]</code></pre>
评论 #42882529 未加载
donatj4 months ago
I wrote a similar maybe hacky script using `git blame` on every file. In our main application, we still have a couple lines from the initial commit in 2011.
lionkor4 months ago
At my old job, I remember it was some time at the beginning of the 1990s. I was born like 8 years after the code I was working on was written.
评论 #42882565 未加载
rozenmd4 months ago
&gt; README.md 2021-01-28 17:27:57 +1100<p>Huh, TIL the birthdate of my business was actually a couple of days ago.
ceejayoz4 months ago
I suspect it&#x27;ll be index.php&#x27;s &lt;?php line, lol.
评论 #42884295 未加载
password43214 months ago
Always start your git repos with an empty commit, right?
评论 #42881485 未加载
评论 #42885661 未加载
inglor_cz4 months ago
Sep 30, 2008 at 5:03:58pm, revision 1.<p>It is SVN, though, and not Git.
kridsdale34 months ago
What if my repo is older than git?
评论 #42884207 未加载