Git diff filter gives reverse output for D(deleted) and A (added)

Hi,

I deleted two files (test1.json and test2.json) from my repository branch and run following command
git diff --name-status current_commit_id previous_commit_id

I was expecting output
D test1.json
D test2.json

but I got actual out as
A test1.json
A test2.json

I ttried adding them back and then I got output

D test1.json
D test2.json

Not sure if I am doing anything wrong… Any help?

Order matters when comparing things with git diff. With current_commit_id previous_commit_id in that order you’ll see what changes there are going from current_commit_id to previous_commit_id, which would be your file getting added back in. Try this: :wink:

git diff --name-status previous_commit_id current_commit_id
1 Like

Hi,

I deleted two files (test1.json and test2.json) from my repository branch and run following command
git diff --name-status current_commit_id previous_commit_id

I was expecting output
D test1.json
D test2.json

but I got actual out as
A test1.json
A test2.json

I ttried adding them back and then I got output

D test1.json
D test2.json

Not sure if I am doing anything wrong… Any help?

[Staff edit: Merged duplicate topics]

894475738