Skip to content

Instantly share code, notes, and snippets.

@sloanlance
Last active October 28, 2016 19:53
Show Gist options
  • Save sloanlance/c5835ac2b60d3d7f3d4f197de528d3f9 to your computer and use it in GitHub Desktop.
Save sloanlance/c5835ac2b60d3d7f3d4f197de528d3f9 to your computer and use it in GitHub Desktop.
git: A git extension to add a filename to the local repository's `exclude` file.
#!/bin/sh --
# Save as "git-exclude" and set the executable flag.
# Execute as "git exclude repo_path file_path"
if [ $# -ne 2 ]; then
echo "usage: $(basename $0 | sed 's/-/ /g') <repo-dir> <file-path>" > /dev/stderr
exit $(false)
fi
fullfilepath="${1}/${2}"
if [ ! -f "${fullfilepath}" ]; then
echo "File \"${2}\" not found in repo \"${1}\"." > /dev/stderr
exit $(false)
fi
echo "${2}" >> "${1}/.git/info/exclude"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment