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

Re: rm and mv commands: should I use them?

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 7, 2008, 02:05 UTC
Message-ID
<7v63y62xwj.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<20080107015518.GD17748@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
> I haven't looked to see if this optimization is in place, but "git mv"
> can also avoid having to recompute the sha1 of the file (which in most
> cases doesn't matter, but on a large file with a cold cache, can make
> the operation seem just as snappy as a regular "mv").
Actually, I think I found a bug.
	$ git reset --hard
	$ echo >>Makefile
        $ git diff --numstat
        1	0	Makefile
        $ git mv Makefile makefile
        $ git diff
        $ git diff --cached -M --numstat
        1	0	Makefile => makefile

"git mv" should not have staged the change. It should have moved the index entry from Makefile to makefile and moved the work tree files.

The fix for this would fall out from your "optimization" quite naturally, but I think that might be a post 1.5.4 item.

Previous: Jeff KingNext: Jeff King
Message 7 of 11 in “rm and mv commands: should I use them?”
  1. Jon HancockJan 6, 2008
  2. David BrownJan 6, 2008
  3. Brian SwetlandJan 6, 2008
  4. Jeff KingJan 6, 2008
  5. Linus TorvaldsJan 6, 2008
  6. Jeff KingJan 7, 2008
  7. Junio C HamanoJan 7, 2008
  8. Jeff KingJan 7, 2008
  9. Robin RosenbergJan 7, 2008
  10. Jay SoffianJan 7, 2008
  11. David BrownJan 7, 2008

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.