These are my notes on Git ignore.
I recently received a PR proposing some changes to a
.gitignore file. One of the lines was formatted as follows:
MANIFEST.SKIP etc. for Perl distributions, the line puzzled me, since I believed it to be resolving based on the file system root, but apparently the root relative to the
From the Git documentation:
The pattern hello.* matches any file or directory whose name begins with hello.. If one wants to restrict this only to the directory and not in its subdirectories, one can prepend the pattern with a slash, i.e. /hello.*; the pattern now matches hello.txt, hello.c but not a/hello.java.
About Gitignore in General
When you create a new repository on GitHub you can specify a
.gitignore based on the language of your choice. I have some older repositories where I have not added this and sometimes I set up no–GitHub repositories so they are created without a good initial
All of the files used by GitHub are available in a repository, so you can easily fetch them from there.
If you are in the first scenario, you can use the
gh-gitignore, which will enumerate all of the available files using
If you are not using
gh you could just use
curl or similar
.gitignore for Go:
curl -o gitignore https://raw.githubusercontent.com/github/gitignore/main/Go.gitignore
Resources and References
- Git documentation: gitignore
- GitHub: gitignore - collection of gitignore examples
- gh extension: gh-gitignore