0

I'd like to review that Git is going to properly detect files as moved, rather than deleted/added new - but there doesn't seem to be any way to preview the operation - it seems like my only option is git add . --dry-run, which then I can't see the resulting status of. Is there any other option?

I expected git commit --dry-run . would work, but it still excludes the untracked files.

Slbox
  • 10,957
  • 15
  • 54
  • 106

1 Answers1

1

I'd like to review that Git is going to properly detect files as moved, rather than deleted/added new ...

This kind of detection happens long after you've committed, and is optional, on a per-"maybe-detect-maybe-don't" basis. That is:

git diff --no-renames <old> <new>

or:

git diff --find-renames[=<threshold>] <old> <new>

presents two different views of the difference between some old and new commit.

Neither view is "more accurate". Imagine you're looking at a big building, like the Empire State Building in NY or the Shard in London or the Burj Khalifa in Dubai. Which view is more accurate: one from a drone, one from the street, or one looking at parts of the interior? The view you see, depending on which of these you select, is different; but the building hasn't changed. The same is true of Git's commit snapshots: once made, a commit's snapshot cannot be changed. It is frozen for all time. It is the way it is, and nothing can change that. Comparing that snapshot to another snapshot just gives you one particular view of that snapshot ("you already know what the old one was, so here's how I describe how the new one differs").

Consider using git add and then git status: the git status command defaults to doing move-detection with the threshold level set to 50%, which is also the default for git diff in modern Git (since Git version 2.9).

torek
  • 448,244
  • 59
  • 642
  • 775