10

I'm new to Haskell and Stack. When creating a new project using stack new which files should be checked in to git (or any other VCS)? The whole dir?

dimid
  • 7,285
  • 1
  • 46
  • 85
  • In general, source code files are what should be getting versioned by Git (or any other VCS tool for that matter). – Tim Biegeleisen Oct 19 '16 at 22:38
  • 2
    Related (partial duplicate): [Is the stack.yaml file supposed to be checked into version control?](http://stackoverflow.com/q/31628186/2751851) – duplode Oct 19 '16 at 22:42
  • @TimBiegeleisen Right, the `src` dir should obviously be included, but what about the rest? suxh as `stack.yml` . E.g. in RoR projects there are non source code files which are also checked in (e.g. `Gemfile`). – dimid Oct 19 '16 at 22:42
  • @duplode Thanks, what other files should be checked in? – dimid Oct 19 '16 at 22:44
  • 4
    Potential close voters: it is not "primarily opinion-based" to say that if you are using a project management tool such as Stack, whose primary goal is making builds fully reproducible, you are supposed to commit the configuration files necessary to make the builds reproducible. – duplode Oct 19 '16 at 22:56

2 Answers2

10

You should check in stack.yaml, either package.yaml (if your project has it) or your-project-name.cabal (if it hasn't), and Setup.hs, as they are necessary for building your project in a reproducible way. The src, app and test directories should also be committed, as they in principle are where your source code will live (you can of course rearrange the structure of the default project if you wish to do so). On the other hand, you should ignore the .stack-work directory, as it contains the build output and other volatile pieces of data.

duplode
  • 33,731
  • 7
  • 79
  • 150
  • Thanks, I guess also `src`, `app`, `test` and `Setup.hs` ? – dimid Oct 19 '16 at 22:49
  • Is this still correct today? I guess today we should include package.yaml, in which case we should ignore your-project-name.cabal since it is generated based on package.yaml? – Martinsos Jun 18 '21 at 13:40
  • @Martinsos Yup, with the caveat that having a package.yaml is optional. I have edited the answer; thanks. – duplode Jun 18 '21 at 23:17
4

You can have a look at the recommended Haskell .gitignore on GitHub:

dist
dist-*
cabal-dev
*.o
*.hi
*.chi
*.chs.h
*.dyn_o
*.dyn_hi
.hpc
.hsenv
.cabal-sandbox/
cabal.sandbox.config
*.prof
*.aux
*.hp
*.eventlog
.stack-work/
cabal.project.local
cabal.project.local~
.HTF/
.ghc.environment.*

If you run the stack new --bare yesod-mysql stack template it includes the following .gitignore:

.stack-work/
yesod-mysql.cabal
*~
icc97
  • 11,395
  • 8
  • 76
  • 90