I would like to maintain history of files within a sub-folder of a repo. But I need to rename the top level folder name. When I run 'git mv dirName newDirName I get 'Fatal: source directory is empty;'
My source directory has the following structure:
gitRepoDir
--.git
--Source
-- -DirLevel2
-- --DirLevel3
-- --DirLevel4
-- --DirLevel5
+++ --DirNameToRename
+++ --sub1dir
+++ --File
+++ --sub2dir
+++ --File
+++ --sub3dir
+++ --File
+++ --File
+++ --sub4dir
+++ --File
Is there a way to rename the top level folder and maintain history of the files in the below subfolders? Or do I need to create the directory structure first then move the files with the git mv command?
We use the git mv command in git to rename and move files. We only use the command for convenience. It does not rename or move the actual file, but rather deletes the existing file and creates a new file with a new name or in another folder.
Set the new URL as the origin of the current directory. This is the same directory where you have filtered code from the previous git repository. Next, verify that the Git origin URLs have been updated in the current directory. Finally, Push all the files to the new repository.
I think it, 'Fatal: source directory is empty;', means dirName is not under git control because it's not part of source. For example, you can try "git status", to figure out whatever can be controlled by git.
you should just tell git mv to skip any operation leading to failure condition
git mv -k dirName newDirName
Usually, the pathname used in git command is a relative path started from current directory.
So for your question, followings should be checked.
1) Whether dirName is a directory managed by git. you can use command git ls-files
2) Whether dirName folder is under current director.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With