This still confuses me. Do you mean to say "use the .gitignore functionality, and check in the .gitkeep file"?
No. Use a .gitignore instead of .gitkeep. Instead of checking in build/.gitkeep, check in build/.gitignore.
No. Use a .gitignore instead of .gitkeep. Instead of checking in build/.gitkeep, check in build/.gitignore.