Skip to content

Instantly share code, notes, and snippets.

@ppanyukov
Created August 2, 2016 12:43
Show Gist options
  • Save ppanyukov/1daad8219a17bf89a5476ef4bc02ad65 to your computer and use it in GitHub Desktop.
Save ppanyukov/1daad8219a17bf89a5476ef4bc02ad65 to your computer and use it in GitHub Desktop.
git cheat sheet

Having the exitng git repo with this structure:

+
|
+-- bin/
|
+-- html/

We want to move everythihng under src directory like this:

+
|
+-- src/
    |
    +-- bin/
    |
    +-- html/

The git command to use:

git filter-branch --prune-empty --tree-filter '
    MOVE_TO="src"
    mkdir -p ${MOVE_TO}
    git ls-tree --name-only $GIT_COMMIT | xargs -I files mv files ${MOVE_TO}
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment