Skip to content

Instantly share code, notes, and snippets.

@fastzombies
Created May 26, 2017 21:24
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fastzombies/d5b5cfc6dce8e187e8ab48a9ed87a5c3 to your computer and use it in GitHub Desktop.
Save fastzombies/d5b5cfc6dce8e187e8ab48a9ed87a5c3 to your computer and use it in GitHub Desktop.
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