Home > other >  How to delete parent directories without deleting its children directories in git?
How to delete parent directories without deleting its children directories in git?

Time:02-11

I have a git repository that has the file structure of /react-projects/programming-todo-list/programming-todo-list/*

I want to delete the upper directories /react-projects/programming-todo-list so that it ends up looking like this : programming-todo-list/*

Is there a way to delete the upper directories without deleting the children directories?

CodePudding user response:

git mv programming-todo-list ../.. is enough if you don't want to impact your past commits (which would still display programming-todo-list in its former place).

If you can rewrite the history of your repository, then git filter-repo (Python-based, to be installed first) is the right tool, using path-based filtering:

git filter-repo --path-rename react-projects/programming-todo-list/programming-todo-list:programming-todo-list
  •  Tags:  
  • git
  • Related