Skip to content
Mark Lavi edited this page Aug 13, 2023 · 11 revisions

The on_git_branch command is very useful, e.g.:

if on_git_branch; then
  echo && git status --short --branch &&
  echo && git fetch --verbose
fi

It is recommended to globally omit some or all direnv related files and directories to:

  1. prevent accidental commits of sensitive information (e.g.: password credentials in .env)
  2. maintain consistent policy, rather than configure each project's .gitignore
git config --global core.excludesfile "~/.gitignore_global"
cat <<EXCL >> ~/.gitignore_global
# Direnv stuff
.direnv
.envrc
EXCL

It is a matter of preference, but some choose to commit a portion of a project's direnv configuration.

Bonus Tip

Git's global ignore file is also handy to skip OS-specific generated files, such as:

cat <<EXCL >> ~/.gitignore_global
# OS generated files #
######################
.DS_Store
ehthumbs.db
Icon?
Thumbs.db
EXCL

or editor specific files:

cat <<EXCL >> ~/.gitignore_global
# Editor files #
################
*~
*.swp
*.swo
EXCL

See gitignore.io for many more examples.