Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4038280
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:27:13+00:00 2026-05-20T12:27:13+00:00

Case Quite often I find myself staring at some old code that doesn’t look

  • 0

Case
Quite often I find myself staring at some old code that doesn’t look right. It looks like something has been removed (e.g. it has a loop that does nothing of value, or it creates a variable but doesn’t use it), or something is just hard to understand the point of. In these cases I would really need to see the history of that section of the file. Not all of the file though, just that section, or function.

Ideal solution
A simple command like

git log books.cpp:10

to find history of line 10 (possibly with surroundings) of file books.cpp is probably too much magic to ask for, but do you have ideas of how to work out that history?

What I have tried
I have tried using blame, and then checking out the commit before the given commit of that line – repeating it until I’ve seen enough. But that is very tedious work.

Have you felt the need for this feature? Do you have a way of achieving it? Share your experience!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T12:27:14+00:00Added an answer on May 20, 2026 at 12:27 pm

    Git is very easy to extend. Does something like this achieve what you want?

    #!/bin/bash
    
    FILENAME=$1
    LINENUMBERS=$2
    
    for hash in `git log --pretty=format:%h ${FILENAME}`
    do
        echo "***************** Showing ${FILENAME} at ${hash}"
        git blame -L ${LINENUMBERS} ${hash} ${FILENAME}
    done
    

    Put this little script in your path as something like git-linehistory and call it like this:

    git linehistory books.cpp 5,15
    

    It will show you what lines 5 to 15 look like at each commit for that file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can't quite figure out this syntax problem with a case expression in a
In the case of languages that support single decision and action without brackets, such
case i of 0..99 : Function-call('bobo') ; 100..209 : function-smell('Hobo'); 210..300 : function-yikes('argh'); end;
The case goes as following: You have a Boolean property called FullScreenEnabled. You enter
Use case: A does something on his box and gots stuck. He asks B
Use case: 3rd party application wants to programatically monitor a text file being generated
Simple case: i put a DataTable in Cache DataTable table = SomeClass.GetTable(); Cache[test] =
I was using a CASE called MAGIC for a system I'm developing, I've never
Kind of a special case problem: I start a process with System.Diagnostics.Process.Start(..) The process
Given the case I made two independent changes in one file: eg. added a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.