Skip to content

Instantly share code, notes, and snippets.

@nflint
Created May 13, 2016 20:00
Show Gist options
  • Save nflint/44712c41b38fbfed1bfa2555fbe053ae to your computer and use it in GitHub Desktop.
Save nflint/44712c41b38fbfed1bfa2555fbe053ae 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
@mgaffigan
Copy link

Powershell version:

Compress-Archive -Files (git ls-files --others --exclude-standard) -DestinationPath "path\to\file.zip";
git clean -d -f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment