Skip to content

Instantly share code, notes, and snippets.

@nflint
Created May 13, 2016 20:01
Show Gist options
  • Save nflint/b5fe1668427735ad560b0cbe0c40560c to your computer and use it in GitHub Desktop.
Save nflint/b5fe1668427735ad560b0cbe0c40560c to your computer and use it in GitHub Desktop.
Git command to export untracked files.
git ls-files --others --exclude-standard -z | cpio -pmd0 path/to/directory
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
# from https://snipt.net/akaihola/move-untracked-files-outside-a-git-repository/
# * 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