Skip to content

Instantly share code, notes, and snippets.

@ethers
Last active August 29, 2015 14:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ethers/4f2cab393d13b8000c55 to your computer and use it in GitHub Desktop.
Save ethers/4f2cab393d13b8000c55 to your computer and use it in GitHub Desktop.
move untracked files outside a git repository
# Found from https://snipt.net/akaihola/move-untracked-files-outside-a-git-repository/
git ls-files --others --exclude-standard -z | cpio -pmd0 ../untracked/
# git clean -d -f
# git ls-files: print a
# * null-delimited (-z) list of
# * untracked (--others)
# * non-ignored (--exclude-standard) files.
# cpio:
# * copy (-p)
# * files in a null-delimited list (-0)
# * create missing directories (-d)
# * preserve modification times (-m)
# git clean: remove untracked non-ignored files
# * and empty directories (-d)
# from the working tree
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment