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

Re: git diff --name-status for deleted files

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 15, 2017, 02:57 UTC
Message-ID
<xmqq1sn8zn1d.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<PS1PR0601MB1883177814CA771567A7193B8A6F0@PS1PR0601MB1883.apcprd06.prod.outlook.com>
Gene Thomas <gene@nlc.co.nz> writes:
Show 5 quoted lines
> Hello,
>           "git diff -name-status" is useful to list the files one
>           has changed but it does not list file that one has
>           deleted with "git rm". It would be really handy if it
>           did. I am using git 2.9.3 on Ubuntu Linux 16.10.

With or without --name-status option, "git diff" compares between the contents you have in the index and in your working tree. After you modify contents of a file, i.e.

	edit file
	git add file

you would not see that file edited exactly because the file on the filesystem is identical to what you added to the index with "git add".

Your example works exactly the same way. Instead of modifying the contents of a file, removing the presense of the file and recording that fact to the index (i.e. removing the path from the index, too) is done with "git rm", so after running

	git rm file

your working tree would lack "file" and so would your index. Hence you wouldn't see "git diff" report any difference on "file".

Perhaps you wanted "git diff HEAD", which is a way to compare between the contents you have in the tip commit and the paths in your working tree thru the index?

Previous: Gene ThomasNext: Gene Thomas
Message 2 of 4 in “git diff --name-status for deleted files”
  1. Gene ThomasSep 14, 2017
  2. Junio C HamanoSep 15, 2017
  3. Gene ThomasSep 15, 2017
  4. Junio C HamanoSep 15, 2017

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.