Satyaki Das
Satyaki Das

Reputation: 157

How to delete unnecessary outer folder in github

My folder structure looks like this:

1.Outer folder
1.1 Inner Folder
1.1.1 .....Main files

Now the outer folder is a git folder that we get after creating a new repo and cloning it while the inner folder is the folder that you get when creating a new react native app. Essentially I should have created the RN app before and then add it to my Github. Now the problem is I have this unnecessary outer folder that does nothing so I want to remove it. What is the easiest way to do this?

Upvotes: 0

Views: 308

Answers (1)

zigarn
zigarn

Reputation: 11595

You can simply move the content of the inner folder at the root of the repository:

git mv innerfolder/* .
rmdir innerfolder
git commit --message "move folders one level up"

If you want to change the whole history to look like it was like this from the beginning, you can use git filter-branch with the option --subdirectory-filter (https://git-scm.com/docs/git-filter-branch#Remap_to_ancestor). Or the more modern git filter-repo with the same option (https://htmlpreview.github.io/?https://github.com/newren/git-filter-repo/blob/docs/html/git-filter-repo.html)

Upvotes: 1

Related Questions