Mike Mike - 10 months ago 35
Git Question

My Git repository is in the wrong root directory. Can I move it? (../ instead of ./)

Somehow when I 'git init'ed my latest project a month or so ago I ran the command in the directory one directory higher than the root of my project.

So my repository is in the

./project directory
and not the
./project/my-new-project directory
. I don't know how I didn't realize the issue earlier, but I just never looked for the .git directory until now.

Is there a way, without killing my project, to move the repository to the proper directory and then tell git what the new base of the project is? Just moving the directory doesn't work. Git thinks all files have been deleted.

Answer Source

Probably the simplest thing, unless you have already created some history you want to save, would be to just delete the .git subdirectory and redo the init in the correct directory.

If you used git to solve the problem, any solution would necessarily leave behind a lot of "moved this file here" history entries that aren't actually changes, but you fixing a screwup at creation time. Better to just create it right.