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

Re: [PATCH] Documentation: clarify git-mv behaviour wrt dirty files

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 3, 2010, 21:56 UTC
Message-ID
<7v3a1idlvg.fsf@alter.siamese.dyndns.org>
In-Reply-To
<c43166fa73391a40b43c27153ec142121fdb71d1.1265231310.git.trast@student.ethz.ch>
Thomas Rast <trast@student.ethz.ch> writes:
> Clearly point out that the rename happens separately for worktree and
> index.  This confused users, as they are apparently told that git-mv
> == git-rm && mv && git-add, which it is not.

I may be confused too as I had to read these three lines three times and I do not think these two sentences mesh well together.

What happens with "git mv A B" is that it moves a work tree file A to B and moves the index entry for A to B, hence all of:

 (1) the fact that you do not have A anymore;
 (2) the fact that you now have B instead; and
 (3) the fact that your work tree file B (which used to be A) has changes
     from its corresponding index entry
are _consistently_ kept between the work tree and the index.

I don't think "happens separately for" makes sense. At best, it is an implementation detail that doesn't help users understand what the command does and what it is used for better.

Of course, it is different from
    "git rm -f --cached A && mv A B && git add B"

which would add changes that you were not prepared to add (i.e. you had output from "git diff A" before you started). I think that was a buggy way old scripted version of "git mv" used to work, by the way.

> While there, move the synposis to the synopsis section, which so far
> was rather useless, and reword the first sentence to eliminate the
> mentions of 'script'.
That's a good change regardless.
> +For every renamed file or symlink, the worktree and index contents are
> +renamed separately, preserving both staged and unstaged changes....
I'd just say:
    While renaming paths, changes in the files in the work tree that you
    have not added are preserved.
> +....  You
> +will still have to commit the rename.

I don't understand why you want to say "You will still have to commit the rename" here. It is like saying in "git add" manpage that "You will still have to commit the added contents" because "add" only affects the index and does not make a commit. Drop it.

Previous: Thomas Rast
Message 20 of 20 in “git-mv redux: there must be something else going on”
  1. Ron GarretFeb 3, 2010
  2. Avery PennarunFeb 3, 2010
  3. Ron GarretFeb 3, 2010
  4. Avery PennarunFeb 3, 2010
  5. Ron GarretFeb 3, 2010
  6. Nicolas PitreFeb 3, 2010
  7. Ron GarretFeb 3, 2010
  8. Ron GarretFeb 3, 2010
  9. Avery PennarunFeb 3, 2010
  10. Ron GarretFeb 3, 2010
  11. Avery PennarunFeb 3, 2010
  12. Jay SoffianFeb 3, 2010
  13. Ron GarretFeb 4, 2010
  14. Ron GarretFeb 4, 2010
  15. Junio C HamanoFeb 4, 2010
  16. Nicolas PitreFeb 3, 2010
  17. Pete HarlanFeb 3, 2010
  18. Ron GarretFeb 3, 2010
  19. Documentation: clarify git-mv behaviour wrt dirty filesThomas Rast, Feb 3, 2010
  20. Junio C HamanoFeb 3, 2010

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.