When I run git-mv file1 file2, I get the file moved from file1 to file2 as I’d expect. Sometimes, though, my git status gives me ‘odd’ output.
When I run git-mv f1 f2, then git status:
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# renamed: f1 -> f2
That’s what I’d expect. Other times, though, after I’ve committed f2, I get:
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# deleted: f1
This generally happens after I’ve committed the new file. I don’t know why it happens – it seems to occur at random (because generally I get the renamed: f1->f2 message, like I’m expecting).
I’d like to know why I sometimes get messages saying I’ve deleted the file after I run git mv, and what steps I’d have gone through to produce this – I’ve just tried to reproduce, and got renamed:..; but 10 minutes ago I got a deleted:... on a file I’d git-mved about 10 minutes before that. It’s confusing me greatly.
It sounds like you renamed
f1tof2, but only committed the addition off2and not the removal off1. This can happen if you usegit mv f1 f2but then typegit commit f2, or it can happen if you typemv f1 f2and then do something likegit add .; git commit