Skip to content

Commit a0ab292

Browse files
committed
docs: update status-vs-diff-index.md
1 parent 14cfd8c commit a0ab292

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

docs/development/advanced/status-vs-diff-index.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ I consider this is an acceptable limitation of functionality to keep the extensi
114114

115115
#### Details
116116

117-
The `diff-index` subcommand cannot see new or moved/renamed files unless you stage them. This is okay. Because you just need to stage a file and then the extension can see it.
117+
The `diff-index` subcommand **cannot** see new or moved/renamed files unless you **stage** them. This is okay. Because you just need to stage a file and then the extension can see it.
118118

119119
And in the case of renaming/moving files, there's a limitation of git that can't be overcome - you need to **stage** the old and new paths anyway for `git` to see them as **one file**, regardless of using `status` or `diff-index`.
120120

@@ -123,3 +123,17 @@ The `git status` subcommand _can_ handle new _untracked_ files. But the effort t
123123
So we just keep things simple to avoid bloating the codebase (adding the ability to use two similar subcommands and handle them both well is not sensible when one subcommand works great for most things).
124124

125125
You can still do what you need to - just remember to stage files if you need the extension to recognize them.
126+
127+
128+
## Find renames
129+
130+
If you move/rename a file and stage that and you also change the contents, you can get `git diff-index` to recognise that as a rename with modification.
131+
132+
This is possible using the `-M` or `--find-renames` flag, which uses the default 50% similarity.
133+
134+
```console
135+
$ git diff-index HEAD --name-status -M
136+
R099 package.json shell/package.json
137+
```
138+
139+
This flag also works for `git status`.

0 commit comments

Comments
 (0)