-1

We're using Hugo to create a blog with static pages. We're working out of the master branch and when ready to deploy to heroku:

  1. We commit all but the public/ files to git
  2. Merge master to the release branch
  3. Within release branch, regenerate /public using Hugo (with production params) and commit
  4. Push to heroku

So we need public/ to be ignored in master, but not in release.

Looking around, I've found this: Using git, how do I ignore a file in one branch but have it committed in another branch?

Problem with that is that the .git/info/exclude and .git/info/exclude_from_master files would have to be manually created for every new user to the repo and they could get the main part (exclude public/) out of sync.

I know that it's not a big deal to just commit the /public files from the master branch as long as we always regenerate them in release before deploy, but assuming I wanted to stick to the original plan, is there a better .gitignore strategy? Seems like I'd want to be able to put "public/" directly in the [branch "master"] section of .gitignore, but I don't believe that works.

Community
  • 1
  • 1
uhezay
  • 341
  • 1
  • 2
  • 11

1 Answers1

0

An ignore file doesn't prevent you from committing anything. It's just that Git doesn't present untracked files matching the ignore file(s) as files that you might want to track.

So, you could simply place public/ in the .gitignore file in the root of your repository to dissuade people from adding files in that directory, then add the Hugo-generated files to the release branch as part of your release process.

Magnus Bäck
  • 11,381
  • 3
  • 47
  • 59
  • Thanks for the clarification. Changed from 'git add .' to 'git add -f public/' on the release branch and that worked perfectly. – uhezay Apr 14 '15 at 23:51