0

I have a working git repository in a subfolder where I would like to now also include the underlying folder.

e.g.

my repo is within:

/var/dir/working/

now I want to also include into the repo

/var/dir/

How can this be achieved in the most easy way?

merlin
  • 2,717
  • 3
  • 29
  • 59
  • 3
    Possible duplicate of [I need git to include the parent directory](https://stackoverflow.com/questions/30740662/i-need-git-to-include-the-parent-directory) – jmargolisvt Feb 07 '19 at 16:15
  • Can you please explain a bit more what so you want? If you want to set /var/dir as your working directory where all the files and folder of git will be inside `/var/dir` directory then please try: 1) Remove `dir` directory from `/var` directory. 2) Then run: `git clone your-git-clone-repo-url dir` inside `/var directory`. – Deepak Biswal Feb 07 '19 at 16:23

1 Answers1

0

I am not sure if the easiest way is to change the .git folder into where it should be.

cd /var/dir/working/
mv .git ../.git # move the .git folder to the parent directory
cd .. # go to parent directory
git status # then you can see a lot of delete and untracked
git add . # output nothing
git status # after add all, you can see those delete and untracked are converted
           # to renaming, and some untracked from "parent directory"
git commit -m "Include parent directory" # you may see a lot of renaming,
                                         # and new file from parent dir, that's it
Geno Chen
  • 4,916
  • 6
  • 21
  • 39