Skip to content

Instantly share code, notes, and snippets.

@JeanDavidDaviet
Created October 29, 2020 08:26
Show Gist options
  • Select an option

  • Save JeanDavidDaviet/15165b61a527b19831f7f88906c7ff83 to your computer and use it in GitHub Desktop.

Select an option

Save JeanDavidDaviet/15165b61a527b19831f7f88906c7ff83 to your computer and use it in GitHub Desktop.
Take a backup of untracked files
# Most of the time, it's safe to delete all the untracked files. But many times, there is a situation wherein you want to delete, but also to create a backup of your untracked files just in case you need them later.
# Git, along with some Bash command piping, makes it easy to create a zip archive for your untracked files.
git ls-files --others --exclude-standard -z | xargs -0 tar rvf ~/backup-untracked.zip
# The above command makes an archive (and excludes files listed in .gitignore) with the name backup-untracked.zip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment