19

I'm using the latest Truffle. Very nice, after having to roll my own dev environment in early 2016! But there is no obvious documentation as to what parts of the project need to be checked into Github.

For example, I'm unsure if the build directory needs to be checked in. I think the answer is 'yes' because one would want to remember what the format of the contracts that have been deployed, but I'm unsure.

6 Answers 6

9

This is the one I'm using rite now. I believe it may be helpful.

>$ cat .gitignore
contracts/.placeholder
test/.placeholder
build
node_modules
3
3

Consensys published an example project and it only has a key file which of course you shouldn't commit and node_modules.

deploy_mnemonic.key
node_modules
2

The answer probably should be - you MUST check in your build directory once you've deployed, because it caches the addresses of your contracts, which is absolutely critical to the truffle deployment system!

so:

>$ cat .gitignore
contracts/.placeholder
test/.placeholder
node_modules
1
2

You could use one of the .gitignore on some well-known ethereum projects on GitHub. Try this: OpenZeppelin's gitignore.

1

I have never used truffle, but my view (and the general rule as I understand) when it comes to source control is that you commit any files and folders that you want to track that can not be recreated.

You should not commit the build directory because the built files can be.. rebuilt. Storing that data would be an unnecessary use of space/bandwidth.

It also necessitates good practices. For example you can build your code, and then modify the source (from which those files are built). If you submitted everything to source control (without rebuilding), another team member might check it out and work with the built files which in this case are not fully up to date.

A brief look at their website implies that this build folder holds compiled contracts. I would not call that a build, but hey-ho :)

In my opinion you would be best served submitting everything to source control except the build folder.

1
  • 2
    But if the network addresses are in these files that makes them important. And who cares about a few kB of bandwidth anyways. You should definitely rebuild and recommit the built files IMO (especially if your app uses the addresses like ours does).
    – JohnAllen
    Oct 27, 2017 at 2:23
0

The answers here are good. Independent from wich project you are wokring on, I would add .DS_Store to any .gitignore file. It's a file used in MacOS for directory settings. So even if you are not using Mac, I would add it. You never know. Maybe you collaborate with a Mac user some day.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.