Change a folder path for commit in Gitlab

Viewed 108

Is there a way to modify folder structure (path) for pushed commits in Gitlab? For example, my old path is homework, now I want to add a parent folder before that, i.e. superfolder/homework? Tks and welcome for any help

1 Answers

If you want to do so while keeping the history of homework, you need to install the Python-based tool newren/git-filter-repo.

That tool has a renaming based on paths option

In your case:

git filter-repo --path-rename homework:superfolder/homework

Note that it changes the history of the repository, which will have to be forced pushed (git push --force): not a big deal if you are the only one working on it.

Related