Skip to contentSkip to conversation

how to track changes of a file

DISCUSSION bill lam 2 participants 4 messages Jun 15, 2016

lore
Share & tools
lore

bill lam

author
#0 lore raw

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,

#1 lore raw
Quoted 7 lines · bill lam

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
Quoted 2 lines

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

$ git show {23335c,31e4f2,b515f0}:glinvc03.ijs
Quoted 1 line

2. show the differences between versions,

$ git log -p -2 -- glinvc03.ijs
Quoted 4 lines

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

author
#2 lore raw
Quoted 4 lines · Johannes Sixt
$ 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
#3 lore raw
Quoted 11 lines · bill lam
Quoted 4 lines · Johannes Sixt
$ 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
Quoted 4 lines
$ 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