Reputation: 17886
I have a
dir1/ contains a lot files and subdirecties, I want to change the directory name to dir2/ . I tried
git mv dir1/ dir2/
I got this message:
fatal: renaming 'dir1' failed: Permission denied
update:
I ran from git for windows command line http://code.google.com/p/msysgit/
What is the correct command?
Upvotes: 21
Views: 28957
Reputation: 1029
I had the same problem. TGitCache.exe was the process that were preventing the folder to be renamed. Using TaksExplorer I have killed the process and run the command from Git Bash command prompt.
Upvotes: 0
Reputation: 22342
You can just use standard unix tools, or whatever your OS is. So:
mv dir1 dir2
should work. Just make sure you add both dir1 and dir2 to the staging area after you've done that, so that you commit the changes.
An example of how to commit the change (once done) could be:
git add dir1 dir2 && git commit dir1 dir2
There's probably other ways to do it too.
Upvotes: 10
Reputation: 91
Both the source and target directory need to be checked into the git repository. If you are moving dir1 to dir2 and dir2 hasn't been committed yet, you will get this error message.
Upvotes: 2
Reputation: 1669
It could also be that the directory (or a file within) is being used by another program, which prevents you from doing anything with that folder. Only on Windows, obviously.
Use the Process Explorer if you're unsure which program has captured that directory/file.
Upvotes: 20
Reputation: 1378
I'm running git in cygwin. I had the same problem until I removed untracked files from the directory to be renamed. That allowed the git mv
to complete properly.
If you see untracked files in your directory to be renamed when you run git status
then you'll have to move those files somewhere else temporarily and bring them back in after the git mv
.
Upvotes: 0