git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Does CVS has a easy way to compare file with its previous version?

From
Andreas Ericsson <ae@op5.se>
Date
Jun 30, 2009, 11:32 UTC
Message-ID
<4A49F7BF.9070209@op5.se>
In-Reply-To
<1e56aa11-735a-47f7-a273-5b6bf611f528@n11g2000yqb.googlegroups.com>
dtletmn wrote:
Show 11 quoted lines
> Hi,All,
> 
>      I am wondering if cvs has an easy way to compare a file with its
> previous version.
> 
>      In clearcase,I can use  :
>        cleartool diff -pred file.cc
> 
>      how can I acheive it in CVS?
>      any help would be highly appreciated!
> 

Why you're posting this to the git mailing list I have no idea, but assuming you mean "how do I compare a file in git with the content it had in the previous snapshot?", the answer would be:

  git diff HEAD^ -- path/to/file

This command works equally well on directories or multiple paths. Note that if there are no differences, the program will just exit silently.

If you want to see the differences compared to the *latest* commit, you'd do

  git diff HEAD -- path/to/file

If you want to see the differences compared to what you've staged for committing next, you'd do

  git diff -- path/to/file

If you want to see the differences between what you've already staged and the latest snapshot, you'd do

  git diff --staged -- path/to/file
-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.
Previous: dtletmnNext: Jakub Narebski
Message 2 of 10 in “Does CVS has a easy way to compare file with its previous version?”
  1. dtletmnJun 30, 2009
  2. Andreas EricssonJun 30, 2009
  3. Jakub NarebskiJun 30, 2009
  4. Paolo BonziniJun 30, 2009
  5. Linus TorvaldsJul 1, 2009
  6. Eric RaibleJul 2, 2009
  7. Paolo BonziniJul 3, 2009
  8. Eric RaibleJul 6, 2009
  9. Paolo BonziniJul 7, 2009
  10. dtletmnJul 1, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.