Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 24th, 2012  |  syntax: None  |  size: 0.73 KB  |  hits: 6  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. git-filter-branch: leave directory structure
  2. |-repository/
  3. |  |  |-repository/fileOne
  4. |  |
  5. |  |-subOne/
  6. |  |  |-subOne/fileTwo
  7. |  |
  8. |  |-subTwo/
  9. |     |-subTwo/fileThree
  10.        
  11. $ git filter-branch --subdirectory-filter subOne --prune-empty
  12.        
  13. $ git log --oneline
  14. 0c0ea11 subOne history
  15. 6318bba subOne history
  16. c96fddb Initial commit
  17.        
  18. $ ls
  19. fileOne
  20. $ pwd
  21. /this/is/a/path/repository
  22.        
  23. To move the whole tree into a subdirectory, or remove it from there:
  24.        git filter-branch --index-filter
  25.                'git ls-files -s | sed "s-t"*-&newsubdir/-" |
  26.                        GIT_INDEX_FILE=$GIT_INDEX_FILE.new
  27.                                git update-index --index-info &&
  28.                 mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE"' HEAD