I created by mistake a local repository and then I cloned my remote repository inside of that repository. Therefore, now my cloned repo is trapped in this outer repository. is there a way I can extract it?
Asked
Active
Viewed 57 times
0
-
Just move the directory, or delete it and re-clone to the correct location? – jonrsharpe Jan 30 '20 at 19:28
-
but I have made changes that I need to push so would just moving the directory solve it? – Joseph hans Bou Assaf Jan 30 '20 at 19:35
-
1I would expect so, the git state is in the .git directory inside the repo directory. – jonrsharpe Jan 30 '20 at 19:35
-
@jonrsharpe May need fixing in [some cases](https://stackoverflow.com/a/13893585/5987698). – GoodDeeds Jan 30 '20 at 19:39
1 Answers
1
Inspired by @jonrsharpe's comment, just move the cloned directory.
On unix-like systems:
$ cd /base/path/repoA/some/repoB
$ git remote -v ## shows the inner repoB
$ cd ..
$ git remote -v ## shows the outer repoA
$ git status ## shows repoB/ as untracked
$ mv repoB /base/path
Then you can push/commit/etc as needed
$ cd /base/path/repoB
$ git commit . . .
$ git push
You don't have to move it to push changes (git will detect which repo you are working in by searching up your directory path and using the first one).

qneill
- 1,643
- 14
- 18