Why would a simple `git mv` fail?

I am trying to rename a file in a local .git directory:

git mv MyProj/src/ts0621/foobar.c NewProjName/src/ts0629/foobar.c

Yet, git fails with:

  • Git: “please tell me who you are” error
  • How to restore files that were removed by git?
  • vs2013 shows file checked in, but in git status the file is untracked
  • git save history of resolved merge conflicts
  • Does GIT support push to an ftp server?
  • How to clone and run another user's Rails app
  • fatal: renaming 'MyProj/src/ts0621/foobar.c' failed: No such file or directory
    

    I could swear that I had git mv working for me when renaming a subdirectory, but for some reason a simple rename of a file doesn’t work. Why?

    (I, of course, verified that the file MyProj/src/ts0621/foobar.c exists before attempting to issue this command)

  • Commit a “virtual” file in git and making it
  • Can two branches point to the same commit?
  • Redmine & Git integration
  • Changing the user running a Jenkins process
  • Git workflow for getting to first release
  • how to do all of operation to the multiple files that are updated, created and deleted at one time
  • 2 Solutions collect form web for “Why would a simple `git mv` fail?”

    Probably, because NewProjName/src/ts0629 doesn’t exist

    Try

    mkdir -pv NewProjName/src/ts0629
    git add NewProjName/src/ts0629
    

    add -f , if the path is relative, to increase git mv -f "originPath" "newPath"

    git mv -f MyProj/src/ts0621/foobar.c NewProjName/src/ts0629/foobar.c
    
    Git Baby is a git and github fan, let's start git clone.