

A Good Use for global .gitignore
source link: https://dev.to/waylonwalker/a-good-use-for-global-gitignore-4kc9
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

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.
Personal Tools
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 aredirenv
and 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
file.
create the config
Like any .gitignore
it supports gits wildignore syntax. I made a~/dotfiles/git/.global_gitignore
file, and added the following to it.
.envrc
.pyflyby
Enter fullscreen mode
Exit fullscreen mode
Once I had this file, I stowed it into ~/.global_gitignore
.
cd ~/dotfiles/
stow git
Enter fullscreen mode
Exit fullscreen mode
Always stow your dotfiles, don't set yourself up for wondering why your next
machine is not working right.
stow note
Note, the reason that it is a ~/.global_gitignore
and not a ~/.gitignore
is 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.
set the config
Next run this command to add the ~/.global_gitignore
to your gitignore as a global excludesfile.
git config --global core.excludesfile ~/.global_gitignore
Enter fullscreen mode
Exit fullscreen mode
commit it
Once you have done this you should have both your ~/dotfiles/git/.gitconfig
and ~/dotfiles/.global_gitignore
ready to commit.
cd ~/dotfiles
git add git/.global_gitignore
git add git/.gitconfig
git commit -m "add global_gitignore"
Enter fullscreen mode
Exit fullscreen mode
You didn't stow your .gitconfig
the shame!
No worries, lets get it into your dotfiles repo and stow it.
cd ~/dotfiles
# if you don't 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
Enter fullscreen mode
Exit fullscreen mode
You don't have a dotfiles directory
double shame 😲
If you don't already have a dotfiles directory 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
Enter fullscreen mode
Exit fullscreen mode
Recommend
-
390
-
68
November 7, 2017 Gitignore.io Template Fork Growing Beyond GitHub’s gitignore Template...
-
101
.ignore 4.x Introduction .ignore is a plugin for: .bzrignore (Bazaar) .chefignore (Chef) .cfignore (CloudFoundry) .cvsignore
-
80
It was a problem for me that Github allows to select single `.gitignore` template, e.g. CMake, and not CMake + C++. I've had...
-
57
README.md A collection of .gitignore templates This is GitHub’s collection of .gitignore file templates. We use this li...
-
64
GitHub is where people build software. More than 27 million people use GitHub to discover, fork, and contribute to over 80 million projects.
-
49
Gitignore.io has been growing slowly and steadily for five years. A lot of that growth is due to the community building tools on top of gitignore.io. I want to highlight some great tools built by the community that use gitignore.io to help you.....
-
41
Blog post explaining what for you might need global .gitignore file. Guides you through creation of this file for Mac OS X.
-
22
Setting it up First, here's the config setup you need to even allow for such a radical concept. Define the global gitignore file as a global Git configuration: git config --global cor...
-
12
Welcome to the Use .gitignore exercise! This exercise checks your knowledge on using a .gitignore file. It is automatically graded via a workflow once you have completed the instructions. About this exercise
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK