I've never found a great use for a global
.gitignore file. Mostly I fear
that by adding a lot of the common things like
.pyc files it will be missing
from the project and inevitably be committed to the project by someone else.
Within the past year I have added some tools to my personal setup that are not
required to run the project, but works really well with my setup. They are
pyflyby. Since these both support project level configuration,
are less common, and not in most
.gitignore templates they make for great
candidates to add to a global
.gitignore it supports gits wildignore syntax. I made a
~/dotfiles/git/.global_gitignore file, and added the following to it.
.envrc .pyflyby .copier-defaults .venv*/ .python-version markout .markata.cache
Once I had this file, I stowed it into
cd ~/dotfiles/ stow git
Always stow your dotfiles, don't set yourself up for wondering why your next machine is not working right.
Note, the reason that it is a
~/.global_gitignore and not a
that I was unable to stow a
.gitignore file. They must be ignored by
default, and I was unable to figure out how to turn it back on.
Next run this command to add the
~/.global_gitignore to your gitignore as a
git config --global core.excludesfile ~/.global_gitignore
Once you have done this you should have both your
~/dotfiles/.global_gitignore ready to commit.
cd ~/dotfiles git add git/.global_gitignore git add git/.gitconfig git commit -m "add global_gitignore"
No worries, lets get it into your dotfiles repo and stow it.
cd ~/dotfiles # if you dont have a git directory make it. mkdir git mv ~/.gitconfig ~/devtainer/git # now use stow to symlink it back to where it was # so git works as expected. stow git
double shame 😲
If you dont already have a dotfiles directry you should. It is important for it to be in your home directory for stow to work properly, if you really don't want it there, look up how to configure stow to account for this.
# make a dotfiles directory and go there mkdir ~/dotfiles cd ~/dotfiles # make it a git repo git init # if you dont have a git directory make it. mkdir git mv ~/.gitconfig ~/devtainer/git # now use stow to symlink it back to where it was # so git works as expected. stow git