Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to change the root directory of a git repository
#!/bin/bash
# This is a reminder script when I need to reset the root of my git repo
# from https://stackoverflow.com/questions/11764003/change-the-root-directory-of-a-git-repository
# /path/to/repo/but/i/want/the/target-dir/* -> /path/to/repo/*
cd /path/to/repo
git filter-branch \
--subdirectory-filter but/i/want/the/target-dir \
--tag-name-filter cat \
-- --all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment