Ignore all .log files with .gitignore
Description: Create debug.log, app.js and a folder build with a file inside. Make Git ignore all .log files and the build folder.
Hint:
- Write the patterns
*.logandbuild/in a file named.gitignore.
Solution
Terminal output
$ mkdir ignore-demo
$ cd ignore-demo
$ git init -q
$ echo "log" > debug.log
$ echo "code" > app.js
$ mkdir build
$ echo "out" > build/out.js
$ printf "*.log\nbuild/\n" > .gitignore
$ git status -s
?? .gitignore
?? app.js
$ git check-ignore -v debug.log
.gitignore:1:*.log debug.log
How it works
- Only
.gitignoreandapp.jsare shown. The log file and the build folder are hidden from Git. git check-ignore -vtells which rule matched.
Read Git Ignore.
Learn more about the similar topics:
| Tutorials |
|---|
| No Content Found. |
| Exercises & Assignments |
|---|
| No Content Found. |
| Interview Questions & Answers |
|---|
| No Content Found. |