Search code examples
linuxgitfilesystemsmount

How to move a Git directory without causing havoc


I have the following file structure, and /var/www/website1 is being tracked by Git.

/var/www/website1/directory1/subdirectory1_1/
/var/www/website1/directory1/subdirectory1_2/
/var/www/website1/directory2/subdirectory2_1/
/var/www/website1/html/

I now wish to move /var/www/website1/directory1/subdirectory1_2/ to /home/user1/subdirectory1_2/, but then mount this directory back at its original location. But if I move the directory, Git is going to think they have all been deleted out of the Git directory, right? Can I temporarily turn Git off while I make the changes? Will doing this cause any hardship?

PS. If you are curious why I am doing this, please see https://superuser.com/questions/752226/giving-remote-access-to-files-for-only-a-single-directory-on-a-linux-server


Solution

  • But if I move the directory, Git is going to think they have all been deleted out of the Git directory, right?
    

    No, Git is smart enough to figure it out. I moved the directory and mounted it back as described, and Git resolved the changes and showed no modified or deleted files as desired.