Git: I need to add files that live above the repo root
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)
2 Solutions collect form web for “Git: I need to add files that live above the repo root”
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
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?