Live data from Hacker News

Ask HN: Do you ever truly use your revision history?

news.ycombinator.com

31–40 of 287 posts

Re: Ask HN: Do you ever truly use your revision history?

#31
I often wonder:

- What is this trying to accomplish?

- Why are you doing it this way?

- Why not this other way?

Ideally these things would be answered in comments, but they often aren't. The commit message hopefully answers #1, and it links to the code review tool which may shed light on the others.

Re: Ask HN: Do you ever truly use your revision history?

#32
post #20

I use it to find more detail about a particular line. Often knowing when something was added, who added it and what was the commit message helps me understand the reasoning behind some particularly weird or legacy code. In some projects this can lead you to a pull request link, with even more context.

I'd second that. I've also used old revisions to try and figure out when a particular bug I've found was introduced too.

Depending on how long it's been there can help you assign a priority, e.g. minor bug has existed for 10 years without anyone noticing is probably not something you have to fix right now. The opposite of that is a nasty bug has existed for 10 years until some data structures or control flow changed and exposed it, so it's not a hard and fast rule.

Once or twice I've seen bugs be introduced by merging huge commits from another branch, so there's lessons to be learned from history too. In this case, avoid large merges with conflicts, especially something you cherry-picked.

Re: Ask HN: Do you ever truly use your revision history?

#33
Yes, every day. Well-written commit messages are like comments that never go out of sync with the code they’re attached to. Often it’s the stuff from years (vs months) ago that’s the most valuable, because that’s the information that nobody who still works at the company can remember.

Re: Ask HN: Do you ever truly use your revision history?

#34
> they haven't transitioned from SVN to git solely because of the logistical challenge of migrating 30 years of commits

lol, I don't think that's the reason. At the only place I worked that used SVN the real reason was that the old guys didn't want to learn something new.

Re: Ask HN: Do you ever truly use your revision history?

#35
post #19

Frequently. Just this evening I was looking in the HN repository for the last version of the code that pg wrote, to remind myself how he used to do something. One of my favorite tricks is to make a file out of all the changes in the history: git log -p > bigass and then grep through the file (edit: which I like to do in Emacs—hence the file) to see every appearance of some construct. There's a lot of knowledge in the…

Along these lines: git-log has a --grep option which returns only commit messages that match a regex, and git-grep searches over revision controlled files like above.

>I like to work on small systems and prevent them from becoming large systems.

This is very wise!

Re: Ask HN: Do you ever truly use your revision history?

#36
Our codebase is around 20 years old and was in CVS, then SVN, then git. Then several years after git, a new git repo without any history due to poor use of the first git repo (someone added binaries, bloated the repo to GBs instead of maybe 200-300MB, which made git export horridly slow).

In all the steps we preserved the commit history, except for the final git->git. However also when we moved from SVN to git we kept the old svn server running as a historical archive for several years, as we didn’t carry across all projects (some were already EOL’d years ago).

During that time I looked at it maybe twice, and ultimately we decommissioned it.

Likewise with the new/old git repos, we still have the old git repo if we need the history.

One final thought: git blame was nice, until someone reformatted the entire codebase and committed it back in (we’ve since adopted better git workflow and code review practices!)

Re: Ask HN: Do you ever truly use your revision history?

#37
Very rarely, beyond a couple weeks of commits. In those cases it is more a question of "did some particular commit hit branch XYZ?". I wouldn't call that source-control-arachaeology.

I'm at the stage where if someone suggests that we try to keep a linear history in git I push back and argue that it isn't worth the extra effort compared to the gains.

Re: Ask HN: Do you ever truly use your revision history?

#38
There are numerous comments showing why git history is useful, but I think nobody mentioned this.

In Goland/idea you can look on the git history of only the selected code. I use this constantly to see how the code has been previously modified before I make my own changes.

Re: Ask HN: Do you ever truly use your revision history?

#39
> they haven't transitioned from SVN to git solely because of the logistical challenge of migrating 30 years of commits.

I did such a migration 3 years ago at a company that had a 10 year history and it was fine using the standard tool. Is there a particular problem your company has with it, or have they just not tried?

(Also, if they are really worried, nothing to stop them keeping a read only SVN server somewhere.)

Re: Ask HN: Do you ever truly use your revision history?

#40

Our codebase is around 20 years old and was in CVS, then SVN, then git. Then several years after git, a new git repo without any history due to poor use of the first git repo (someone added binaries, bloated the repo to GBs instead of maybe 200-300MB, which made git export horridly slow). In all the steps we preserved the commit history, except for the final git->git. However also when we moved from SVN to git we kep…

You can use git log -S and the regex of the line to see how that line changed over time. It is also called git pickaxe. Also git diff has an ignore white space which basically ignores formatting stuff if that is the case. I believe that git log has it also.
Post reply on HN