Re: How do I get the correct modification status after running git diff?
- From
Michael J Gruber <git@drmicha.warpmail.net>
- Date
- Mar 4, 2010, 16:34 UTC
- Message-ID
- <4B8FE121.6040807@drmicha.warpmail.net>
- In-Reply-To
- <27782895.post@talk.nabble.com>
jateeq venit, vidit, dixit 04.03.2010 17:11:
> > Ok, so I think I know what I was doing wrong... i wasn't comparing the > working tree with the last commit (HEAD), although I still don't know what > exactly I was comparing the working tree with. On reading the manual a
You were comparing the working tree with the index (staging area).
Show 17 quoted lines
> little more carefully, I realised the command should have been: > > git diff -M --name-status HEAD > > This solves the problem of newly added files, but doesn't show 'R' for > renamed files even after I ask git to detect renamed files - just shows that > the renamed file was deleted (doesn't detect that the new renamed file was > added). So I would still appreciate some input here. > > Renaming flie: > mv randomfile.xml random.xml > > Diffing: > git diff -M --name-status HEAD > > Output: > D randomfile.xml
git doesn't know about random.xml here, which you can change like so:
git add -N random.xml
Then git diff -M --name-status HEAD will show the rename.
Alternatively, you could have used "git mv randomfile.xml random.xml" which would have staged that move in the index already. (More exactly: the content changes, not the move as such)
Michael