# Question: regarding understanding code base

9 messages from 2025-06-14 to 2025-06-16. Participants: JAYATHEERTH K, Junio C Hamano, Ben Knoble.
Thread: https://gitlist.dev/t/63645

## JAYATHEERTH K, 2025-06-14 12:43

Subject: Question: regarding understanding code base
Message-ID: <CA+rGoLf8Lf0gbPEUjTU9Zc9KQrzui4pjyvfxhA-LT4YuafqeOQ@mail.gmail.com>
URL: https://gitlist.dev/e/CA%2BrGoLf8Lf0gbPEUjTU9Zc9KQrzui4pjyvfxhA-LT4YuafqeOQ%40mail.gmail.com

```
Ok so a couple of weeks ago, in this thread[1]
Junio advised that one of the best ways to understand git is to go back to the
_inital commit_ and travel back to the latest ones.

And I happened to quite like this idea, cause I still have to dig up a
lot of things in git.
The main question is
What are the best and smallest set of git commands to do this as
I can set this up as an alias and use this trick for many other projects too.

1 - https://lore.kernel.org/git/xmqqfrh3qe2w.fsf@gitster.g/


Thank you,

- Jayatheerth

```

## Junio C Hamano, 2025-06-14 15:43

Subject: Re: Question: regarding understanding code base
Message-ID: <xmqq8qlu72hz.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqq8qlu72hz.fsf%40gitster.g
In-Reply-To: <CA+rGoLf8Lf0gbPEUjTU9Zc9KQrzui4pjyvfxhA-LT4YuafqeOQ@mail.gmail.com>

```
JAYATHEERTH K <jayatheerthkulkarni2005@gmail.com> writes:

> The main question is
> What are the best and smallest set of git commands to do this as
> I can set this up as an alias and use this trick for many other projects too.

Sorry, but I have no idea what you are trying to refer to as "this"
in "commands to do this" and also "this" in "use this trick", so I
cannot help you here.



```

## JAYATHEERTH K, 2025-06-15 00:24

Subject: Re: Question: regarding understanding code base
Message-ID: <CA+rGoLehMUWPMBrZ1hOk-GBQBCvSY0_ivFCn1w1C-V_bGTDgZg@mail.gmail.com>
URL: https://gitlist.dev/e/CA%2BrGoLehMUWPMBrZ1hOk-GBQBCvSY0_ivFCn1w1C-V_bGTDgZg%40mail.gmail.com
In-Reply-To: <xmqq8qlu72hz.fsf@gitster.g>

```
On Sat, Jun 14, 2025 at 9:13 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> JAYATHEERTH K <jayatheerthkulkarni2005@gmail.com> writes:
>
> > The main question is
> > What are the best and smallest set of git commands to do this as
> > I can set this up as an alias and use this trick for many other projects too.
>
> Sorry, but I have no idea what you are trying to refer to as "this"
> in "commands to do this" and also "this" in "use this trick", so I
> cannot help you here.
>
>

What I meant was:
You previously suggested that one good way to understand Git is to
start from the initial commit of the Git repo and move forward
chronologically through the commits.

I'd like to turn this approach into a repeatable workflow, possibly
through an alias or small script.

So my question is:
What is the smallest and most effective set of Git commands to:

- Start from the initial commit of a repository

- Walk forward through history (one commit at a time) probably which
changes my file system (I currently use a terminal based command)

I use
git rev-list --reverse HEAD | while read commit; do
  echo "=== Commit: $commit ==="
  git show --color --stat --patch --pretty=fuller "$commit"
  read -p "Press enter to continue to the next commit..."
done

I wanted to know if there are any better ways

Thanks again,
- Jayatheerth

```

## Ben Knoble, 2025-06-15 00:26

Subject: Re: Question: regarding understanding code base
Message-ID: <AF617F39-7B22-44A3-BF08-D21CCFBEBD20@gmail.com>
URL: https://gitlist.dev/e/AF617F39-7B22-44A3-BF08-D21CCFBEBD20%40gmail.com
In-Reply-To: <CA+rGoLf8Lf0gbPEUjTU9Zc9KQrzui4pjyvfxhA-LT4YuafqeOQ@mail.gmail.com>

```

> Le 14 juin 2025 à 08:44, JAYATHEERTH K <jayatheerthkulkarni2005@gmail.com> a écrit :
> 
> ﻿Ok so a couple of weeks ago, in this thread[1]
> Junio advised that one of the best ways to understand git is to go back to the
> _inital commit_ and travel back to the latest ones.
> 
> And I happened to quite like this idea, cause I still have to dig up a
> lot of things in git.
> The main question is
> What are the best and smallest set of git commands to do this as
> I can set this up as an alias and use this trick for many other projects too.

If you want a checkout of the root commit, assuming there’s only one, something like

    git rev-list | sed -n \$p | xargs git switch --detach

ought to work. You could feed something similar to git-worktree. But it’s a little harder to “go forward” with Git’s data model, and I didn’t totally understand “travel back to the latest ones.”

> 
> 1 - https://lore.kernel.org/git/xmqqfrh3qe2w.fsf@gitster.g/
> 
> 
> Thank you,
> 
> - Jayatheerth
> 

```

## JAYATHEERTH K, 2025-06-15 00:37

Subject: Re: Question: regarding understanding code base
Message-ID: <CA+rGoLcKfWYYSc-ORC9pCsUzsqketFdfVruwTC0Q06+BN5Gb7w@mail.gmail.com>
URL: https://gitlist.dev/e/CA%2BrGoLcKfWYYSc-ORC9pCsUzsqketFdfVruwTC0Q06%2BBN5Gb7w%40mail.gmail.com
In-Reply-To: <AF617F39-7B22-44A3-BF08-D21CCFBEBD20@gmail.com>

```
On Sun, Jun 15, 2025 at 5:56 AM Ben Knoble <ben.knoble@gmail.com> wrote:
>
>
> > Le 14 juin 2025 à 08:44, JAYATHEERTH K <jayatheerthkulkarni2005@gmail.com> a écrit :
> >
> > ﻿Ok so a couple of weeks ago, in this thread[1]
> > Junio advised that one of the best ways to understand git is to go back to the
> > _inital commit_ and travel back to the latest ones.
> >
> > And I happened to quite like this idea, cause I still have to dig up a
> > lot of things in git.
> > The main question is
> > What are the best and smallest set of git commands to do this as
> > I can set this up as an alias and use this trick for many other projects too.
>
> If you want a checkout of the root commit, assuming there’s only one, something like
>
>     git rev-list | sed -n \$p | xargs git switch --detach
>
> ought to work. You could feed something similar to git-worktree. But it’s a little harder to “go forward” with Git’s data model, and I didn’t totally understand “travel back to the latest ones.”
>

By _travel back to the latest ones_ I think I should have said travel
_forward to the latest ones_

But I meant to incrementally get to the _latest commit_ from the
_initial commit_

```

## Junio C Hamano, 2025-06-15 00:43

Subject: Re: Question: regarding understanding code base
Message-ID: <xmqqldpt6dht.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqqldpt6dht.fsf%40gitster.g
In-Reply-To: <CA+rGoLehMUWPMBrZ1hOk-GBQBCvSY0_ivFCn1w1C-V_bGTDgZg@mail.gmail.com>

```
JAYATHEERTH K <jayatheerthkulkarni2005@gmail.com> writes:

> What I meant was:
> You previously suggested that one good way to understand Git is to
> start from the initial commit of the Git repo and move forward
> chronologically through the commits.

Not at all.  I only suggested to study the initial one.  It is more
like biology students learning the common principles that apply to
all kinds of life by studying a lot simpler organism as a model,
instead of studying a lot higher order ones like mammals.

Moving forward is all your invention or hallucination ;-)

> - Start from the initial commit of a repository
>
> - Walk forward through history (one commit at a time) probably which
> changes my file system (I currently use a terminal based command)
>
> I use
> git rev-list --reverse HEAD | while read commit; do
>   echo "=== Commit: $commit ==="
>   git show --color --stat --patch --pretty=fuller "$commit"
>   read -p "Press enter to continue to the next commit..."
> done
>
> I wanted to know if there are any better ways

Like "git log --reverse -p"?

```

## JAYATHEERTH K, 2025-06-15 00:48

Subject: Re: Question: regarding understanding code base
Message-ID: <CA+rGoLcsuhhSOVJoK2vEV3m7PgH+8hpfpdih2furnyim=0gP+A@mail.gmail.com>
URL: https://gitlist.dev/e/CA%2BrGoLcsuhhSOVJoK2vEV3m7PgH%2B8hpfpdih2furnyim%3D0gP%2BA%40mail.gmail.com
In-Reply-To: <xmqqldpt6dht.fsf@gitster.g>

```
On Sun, Jun 15, 2025 at 6:13 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> JAYATHEERTH K <jayatheerthkulkarni2005@gmail.com> writes:
>
> > What I meant was:
> > You previously suggested that one good way to understand Git is to
> > start from the initial commit of the Git repo and move forward
> > chronologically through the commits.
>
> Not at all.  I only suggested to study the initial one.  It is more
> like biology students learning the common principles that apply to
> all kinds of life by studying a lot simpler organism as a model,
> instead of studying a lot higher order ones like mammals.
>
> Moving forward is all your invention or hallucination ;-)
>

Fair enough I have read your biology metaphor
into a full evolutionary theory.

```

## Junio C Hamano, 2025-06-16 00:40

Subject: Re: Question: regarding understanding code base
Message-ID: <xmqqy0ts4izb.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqqy0ts4izb.fsf%40gitster.g
In-Reply-To: <CA+rGoLcsuhhSOVJoK2vEV3m7PgH+8hpfpdih2furnyim=0gP+A@mail.gmail.com>

```
JAYATHEERTH K <jayatheerthkulkarni2005@gmail.com> writes:

> On Sun, Jun 15, 2025 at 6:13 AM Junio C Hamano <gitster@pobox.com> wrote:
>>
>> JAYATHEERTH K <jayatheerthkulkarni2005@gmail.com> writes:
>>
>> > What I meant was:
>> > You previously suggested that one good way to understand Git is to
>> > start from the initial commit of the Git repo and move forward
>> > chronologically through the commits.
>>
>> Not at all.  I only suggested to study the initial one.  It is more
>> like biology students learning the common principles that apply to
>> all kinds of life by studying a lot simpler organism as a model,
>> instead of studying a lot higher order ones like mammals.
>>
>> Moving forward is all your invention or hallucination ;-)
>>
> Fair enough I have read your biology metaphor
> into a full evolutionary theory.

I should probably have said "before" instead of "instead of" in the
above.  You were looking for a way to see what higher order
organisms there are to study, after learning from the simplest
organism.

"git log --reverse -p" is a simpler replacement for your shell
script loop to do so.

If I were doing this, after studying the initial one, I would
probably see how much of what I learned from the initial version
remains in 1.0.0, 1.3.0, 1.5.3, and 1.6.0.

1.5.3 was probably the last version one can read cover to cover in
one sitting.  Anything after that version are just too big, I think,
but there probably are those with more patience than I have ;-).

```

## JAYATHEERTH K, 2025-06-16 09:44

Subject: Re: Question: regarding understanding code base
Message-ID: <CA+rGoLeG=-PK6QiMKL6YuUYAarnd0rM_iGD=vAUReKYZ9ex9AA@mail.gmail.com>
URL: https://gitlist.dev/e/CA%2BrGoLeG%3D-PK6QiMKL6YuUYAarnd0rM_iGD%3DvAUReKYZ9ex9AA%40mail.gmail.com
In-Reply-To: <xmqqy0ts4izb.fsf@gitster.g>

```
On Mon, Jun 16, 2025 at 6:10 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> JAYATHEERTH K <jayatheerthkulkarni2005@gmail.com> writes:
>
> > On Sun, Jun 15, 2025 at 6:13 AM Junio C Hamano <gitster@pobox.com> wrote:
> >>
> >> JAYATHEERTH K <jayatheerthkulkarni2005@gmail.com> writes:
> >>
> >> > What I meant was:
> >> > You previously suggested that one good way to understand Git is to
> >> > start from the initial commit of the Git repo and move forward
> >> > chronologically through the commits.
> >>
> >> Not at all.  I only suggested to study the initial one.  It is more
> >> like biology students learning the common principles that apply to
> >> all kinds of life by studying a lot simpler organism as a model,
> >> instead of studying a lot higher order ones like mammals.
> >>
> >> Moving forward is all your invention or hallucination ;-)
> >>
> > Fair enough I have read your biology metaphor
> > into a full evolutionary theory.
>
> I should probably have said "before" instead of "instead of" in the
> above.  You were looking for a way to see what higher order
> organisms there are to study, after learning from the simplest
> organism.
>
> "git log --reverse -p" is a simpler replacement for your shell
> script loop to do so.
>
> If I were doing this, after studying the initial one, I would
> probably see how much of what I learned from the initial version
> remains in 1.0.0, 1.3.0, 1.5.3, and 1.6.0.
>
> 1.5.3 was probably the last version one can read cover to cover in
> one sitting.  Anything after that version are just too big, I think,
> but there probably are those with more patience than I have ;-).

Agreed, it takes time to sincerely understand each function

Till now how I've done is
Whenever there was a bug report
I acted like the compiler, tracing the file and function with pen and
paper and found the quirk
While this would work for bug fixes, I'm not sure if this is a good
practice for big projects or a good practice in general.

```
