Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I add go dep vendor/ to .gitignore? [duplicate]

Tags:

go

Should I add go dep vendor/ folder to .gitignore? Now I have vendor/ in .gitignore, so every deploy will call dep ensure

like image 546
Andrei Avatar asked Jun 30 '18 21:06

Andrei


People also ask

Should I add vendor to Gitignore?

The general recommendation is no. The vendor directory (or wherever your dependencies are installed) should be added to . gitignore / svn:ignore /etc. The best practice is to then have all the developers use Composer to install the dependencies.

Should you commit vendor folder?

When dependencies are kept to a minimum, it's easy to commit the entire vendor folder without incurring the huge data cost that the average node_modules folder would demand.

Should .gitignore be added to repository?

Normally yes, . gitignore is useful for everyone who wants to work with the repository. On occasion you'll want to ignore more private things (maybe you often create LOG or something. In those cases you probably don't want to force that on anyone else.

What is vendor directory in go?

js land, Golang's vendor directory is basically the same as Node's node_modules . It is a directory found at the root of a Go module that stores a copy of all the code the module depends on. The vendored code is used to compile the final executable when the go build command is run.


1 Answers

github/gitignore/Go.gitignore doesn't add vendor/ to its .gitignore file.

This causes its content should be versioned, recorded in the Git repository, instead of being potentially generated, and may respond to the following needs:

  • avoiding reference changes
  • dissapearing projects
  • vendoring tool may evolve (dep to vgo to modules), ...
  • if you made modifications to vendor dependencies in your Git repository, you should probably track those

On the other hand, gitignore.io/api/go does add vendor/ to its .gitignore.

So in conclusion, you might as well ignore it if you're not under any of the situations stated above.

like image 70
VonC Avatar answered Sep 20 '22 02:09

VonC