I'm confused. Having a file gitignored doesn't stop you from committing it; AFAIK you can just
touch build/.gitkeep
git add build/.gitkeep
git commit build/.gitkeep
And that's it? There's no need to exclude anything.