threads / discuss / 13976

how to track changes of a file

Subject: how to track changes of a file

## tl;dr

4 messages between Jun 16, 2008 and Jun 16, 2008.

replies: 3people: 2as markdown or json

bill lam· Jun 16, 2008, 10:46 UTC · lore
I want to see what had been done to a particular file, so I started with the log,

$ git-log --no-color glinvc03.ijs |grep commit |head -3 commit 23335cf4acadb9f09410f106adbcc2b190fe9c70 commit 31e4f2c519caa9afa2e29ed8ffb40deb62aa972f commit b515f020d05f2967a7283751c8dd3740de7136a4

I want to know how to,
1. cat the content this file for these 3 versions
2. show the differences between versions,

I use vim to view man page, and git-log without redirection will invoke vim as a man viewer. Does git-log always use man? Without the --no-color option there will be some "33m" prepending to some lines, is there any global setting to turn off color in git-log?

regards,
Johannes Sixt· Jun 16, 2008, 10:56 UTC · re: bill lam · lore

Re: how to track changes of a file

bill lam schrieb:
Show 7 quoted lines
> I want to see what had been done to a particular file, so I started with
> the log,
> 
> $ git-log --no-color glinvc03.ijs |grep commit |head -3
> commit 23335cf4acadb9f09410f106adbcc2b190fe9c70
> commit 31e4f2c519caa9afa2e29ed8ffb40deb62aa972f
> commit b515f020d05f2967a7283751c8dd3740de7136a4
All you neede here probably was just
$ git rev-list -3 -- glinvc03.ijs
> I want to know how to,
> 1. cat the content this file for these 3 versions
$ git show {23335c,31e4f2,b515f0}:glinvc03.ijs
> 2. show the differences between versions,
$ git log -p -2 -- glinvc03.ijs
> I use vim to view man page, and git-log without redirection will invoke
> vim as a man viewer.  Does git-log always use man?  Without the
> --no-color option there will be some "33m" prepending to some lines, is
> there any global setting to turn off color in git-log?
You have set PAGER=vim in your .profile? Then put
GIT_PAGER=less; export GIT_PAGER
there, too.
-- Hannes
bill lam· Jun 16, 2008, 15:49 UTC · re: Johannes Sixt · lore

Re: how to track changes of a file

Johannes Sixt wrote:
> $ git rev-list -3 -- glinvc03.ijs
> 
> 
> $ git show {23335c,31e4f2,b515f0}:glinvc03.ijs

Thank for you help, but these 2 command did not work, did I missing something? I I use git version 1.5.4.3 on linux.

$ git rev-list -3 -- glinvc03.ijs
usage: git-rev-list [OPTION] <commit-id>... [ -- paths... ]
   limiting output:
     --max-count=nr
     --max-age=epoch
     --min-age=epoch
     --sparse
     --no-merges
     --remove-empty
     --all
     --stdin
     --quiet
   ordering output:
     --topo-order
...

$ git show {23335c,31e4f2,b515f0}:glinvc03.ijs fatal: ambiguous argument '23335c:glinvc03.ijs': unknown revision or path not in the working tree. Use '--' to separate paths from revisions

Johannes Sixt· Jun 16, 2008, 16:08 UTC · re: bill lam · lore

Re: how to track changes of a file

bill lam schrieb:
Show 11 quoted lines
> Johannes Sixt wrote:
>> $ git rev-list -3 -- glinvc03.ijs
>>
>>
>> $ git show {23335c,31e4f2,b515f0}:glinvc03.ijs
> 
> Thank for you help, but these 2 command did not work, did I missing
> something? I I use git version 1.5.4.3 on linux.
> 
> $ git rev-list -3 -- glinvc03.ijs
> usage: git-rev-list [OPTION] <commit-id>... [ -- paths... ]
Sorry, should have been
$ git rev-list -3 HEAD -- glinvc03.ijs

But this is not intended for daily use anyway. You are better off using git log family of commands. Eg. if you insist on a 1-commit-per-line listing, you'd use

$ git log -3 --pretty=oneline -- glinvc03.ijs
> $ git show {23335c,31e4f2,b515f0}:glinvc03.ijs
> fatal: ambiguous argument '23335c:glinvc03.ijs': unknown revision or
> path not in the working tree.
> Use '--' to separate paths from revisions

My guess is that glinvc03.ijs lives in a subdirectory of your repo. Then you must supply the complete path from the repository root:

$ git show {23335c,31e4f2,b515f0}:some/subdir/glinvc03.ijs
(No, this will not be changed.)
-- Hannes

← back to recent threads