Skip to content

Instantly share code, notes, and snippets.

@bitdivine
Last active January 31, 2022 02:02
Show Gist options
  • Save bitdivine/38603a2da5f3877a37de5be121636d18 to your computer and use it in GitHub Desktop.
Save bitdivine/38603a2da5f3877a37de5be121636d18 to your computer and use it in GitHub Desktop.
Convert .gitignore files in a repo into a dockerignore file
git ls-files --recurse-submodules --full-name |\
awk -F/ '($(NF) == ".gitignore")' |\
xargs -I{} awk -vx="{}" 'BEGIN{gsub(/[.]gitignore$/,"", x)}/^ *#/{print;next}/./{print x$0}' "{}" |\
awk 'BEGIN{print ".git"}{print}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment