I have an unfortunate situation. I'm using Git 1.7.9 on Windows 7. I have a repo that lives in foo\bar
. Everything is great. However, I just realized that the project requires files that live in foo
. What is the best way to add them to the repo without messing everything up? (I'm new to git. I'm using the Github for Windows client, for what it's worth)
Asked
Active
Viewed 175 times
2

Nick Heiner
- 119,074
- 188
- 476
- 699
-
possibly a dupplicate of: http://stackoverflow.com/questions/1918111/my-git-repository-is-in-the-wrong-root-directory-can-i-move-it-intead-of (the last answer should be your case) – Peter Butkovic Aug 24 '12 at 05:20
2 Answers
1
A clever answer by Abhishek Anand:
Move the .git directory (and any other support files, like .gitignore) to the parent directory. Then, from the parent directory, add the old repository root; git detects the rename and handles it correctly. So, in your example,
foo\bar> move .git ..
foo\bar> cd ..
foo> git add bar
foo> git commit -a
foo> git add .
foo> git commit
0
Change it however you want... git is smart! It will automatically figure out the file renames for you. Each file blob is stored once, so you won't bloat the version history.
I wonder if copying the ".git" folder up a level will work?

EthanB
- 4,239
- 1
- 28
- 46