1

I'm trying to understand if it is possible to determine how a particular line changes "in the future" using git log, i.e., going to an old commit using git checkout and using some variant git log -L to see the future of that line.

Here's what I'm doing:

git clone https://github.com/jMetal/jMetal
cd jMetal
git checkout b5a3d3f2701bab98318a92eaf781653392494b43
git log -L 37,37:README.md

This one only allows me to go backwards though. Is it possible to go forward in a similar way? As far as I understand, git clone should download the entire version history so I'm pretty sure the required information is somewhere already.

C.T
  • 11
  • 1
  • Git fundamentally works backwards: starting from a recent commit, it traverses to each *previous* commit, one commit at a time. The `--reverse` option exists in `git log` to make Git go backwards from its normal order, but many things work less-well this way. Note that you must still tell Git to start with the most recent commit, too! It just generates the list (in its normal backwards order), then walks it in reverse (reversing the backwards list resulting in forwards traversal). – torek May 09 '18 at 15:05

1 Answers1

1

First, find out how many tracked development directions (branches) there have been since the specific commit:

git branch -a --contains b5a3d3f2701bab98318a92eaf781653392494b43

It lists all the branches that contain this commit. For example, there might be origin/foo and origin/bar. These branches are the latest (at the moment the repository is cloned) revision of each direction. Then run

git log -L 37,37:README.md b5a3d3f2701bab98318a92eaf781653392494b43..origin/foo

to see how Line 37 of README.md has been changed since the specific commit till the latest revision of foo.

ElpieKay
  • 27,194
  • 6
  • 32
  • 53