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)

  • How to revert the changes made in file which has not been put in staging area using GIT
  • Reverting under Git
  • why git compress objects first, then receive them? i think it should be reverse
  • How to open google chrome from terminal?
  • Error pushing to proper Heroku Web App
  • git commit 0 line add and remove end line also same but still show modified, what goes wrong?
  • Git reset to previous commit
  • Can you merge and push another branch using git?
  • Github Windows client “loading commits failed”
  • Is it safe to edit source in a repo while the repo is being cloned by another client?
  • editing non-master branch in git
  • Git repository in OneDrive synced folder
  • 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?

    Git Baby is a git and github fan, let's start git clone.