This article is translation of the original post from my blog:
🇵🇱 Git: Jak używać .gitignore i .gitkeep?
If you work with Git and have your repo...
Some comments have been hidden by the post's author - find out more
For further actions, you may consider blocking this person and/or reporting abuse
Awesome article! It's worth noting that if you create a file, then decide that you want to .gitignore that file, you can use
git rm --cached myawesomefile.txt
.This removes the file from the cache, and assuming that your .gitignore is correct, git will then not allow this file back into the cache.
I've never liked using
.gitkeep
when there are ways of using.gitignore
to do the same thing without requiring a hack. Usually, though, my approach is to not store empty directories at all!so you know of a way using .gitignore that will allow you to track empty directories? Please tell.
Yes, instead of naming your empty file, ".gitkeep", name it ".gitignore" :)
If you want to ensure the directory stays empty, put a
*
in it (and possibly! .gitignore
, I can't remember off the top of my head).Using ".gitkeep" means you save an unrelated file to your repository and does not prevent you from accidentally adding whatever generated files end up under that directory in your local working version.
This sentence reads like you probably changed it a bunch while editing and left an extra word in by accident :D
thanks! just some translation oversight :D fixed!
Cool, I knew about .gitignore, but I didn't know about .gitkeep until now.
Great! Nice article @ritaly .
Thanks for sharing. That is high quality content.
You can use empty
.gitignore
file instead of non-standard.gitkeep
.yes, I mention that above, that we can track an empty folder through gitignore - it also works if you prefer that way
I didn't know about gitkeep. Thank you!
Nice article elaborating the details
Interesting :)