0

If I use git mv then it records correctly the rename :

renamed:    oldname -> newname

But if I am just moving some files around and then git add they become unlinked:

deleted:    oldname
new file:   newname

Is there was a simple way to update the staged index, to change the deleted/new-file to a rename?

git version 2.25.0

Ian Vaughan
  • 20,211
  • 13
  • 59
  • 79
  • What's your git version? – Romain Valeri Feb 04 '20 at 11:33
  • 1
    Not really. Git actually doesn't care. – eftshift0 Feb 04 '20 at 11:33
  • 1
    Don't give them hope, @RomainValeri :-D For real, that's a user-level thing, not something that git tracks when committing. – eftshift0 Feb 04 '20 at 11:34
  • as far as I know your have to `git reset` the change and then do `git mv`, if you really care about how things goes in git, but that's not much of different. – ROOT Feb 04 '20 at 11:35
  • To be honest, I tried it out with a simple move without `git mv`, then adding everything, and the file got detected as renamed. Thus my question about version, I was unsure whether older versions did that also. But I guess you're right :-) – Romain Valeri Feb 04 '20 at 11:36
  • 1
    Can you provide a minimal reproducible example? A set of commands that show how `mv` created this state, including a `git status` at the end? – root Feb 04 '20 at 11:49
  • https://stackoverflow.com/search?q=%5Bgit%5D+detect+rename – phd Feb 04 '20 at 13:09
  • "git doesn't care" but I do! "not something that git tracks"/"but that's not much of different" if moved git tracks changes in the files regardless of the rename. – Ian Vaughan Feb 05 '20 at 11:50
  • The question about git detecting automatically is fine on its own, this question is more about if its not detected => then what? Because currently, I do a dance of reset/mv/co/git-mv/ci! – Ian Vaughan Feb 05 '20 at 11:53

0 Answers0