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

Re: move directories in work dir

From
Junio C Hamano <junkio@cox.net>
Date
Oct 23, 2005, 06:24 UTC
Message-ID
<7vzmp04uot.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<6f22540448f7234336a00bce5b6547b6@Splinter>
"Rogelio M. Serrano Jr." <rogelio@smsglobal.net> writes:
> ... is there a way to tell git that i moved a directory into
> another? For example i have.
Before you moved them, you could have done [*1*]:
	$ mkdir analyze/import_tools
	$ git rename analyze/import_a analyze/import_tools/import_a
	$ git rename analyze/import_b analyze/import_tools/import_b
But that may be too late now.  Instead you already did:
	$ mkdir analyze/import_tools
        $ mv analyze/import_a analyze/import_b analyze/import_tools/.
At this point, you can:
	$ git-add analyze/import_tools
	$ git-ls-files analyze/import_a analyze/import_b |
          git-update-index --remove --stdin
> right now i have to do git-update-index --add for everything all over 
> again.

"git rename" is just a short-hand of your manual "git-update-index --add --remove" (and at the same time moving files in the working tree). There isn't any extra information you are giving git by using it (IOW "git" does not record renames).

BTW, do you really have a file whose name ends with an ESC character?

> analyse/import_a/import_a.c
[Footnote]

*1* It strikes me that git rename *could* be friendlier by emulating how "mv" treats the paths parameters (current implementation insists two parameters $src and $dst). What do you think, Ryan?

Previous: Rogelio M. Serrano Jr.Next: Rogelio M. Serrano Jr.
Message 2 of 5 in “move directories in work dir”
  1. Rogelio M. Serrano Jr.Oct 23, 2005
  2. Junio C HamanoOct 23, 2005
  3. Rogelio M. Serrano Jr.Oct 23, 2005
  4. Add support for renaming multiple items at once, and for the destination to be a directory.Ryan Anderson, Oct 31, 2005
  5. Peter EriksenOct 31, 2005

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.