-2

Whenever I run yarn install, .yarn/ folder and .yarnrc.yml are added to my repo. I have to manually remove them all the time before commiting in git.

How can I prevent this behaviour? Why does this happen? Why this is not happening to other team members?

5
  • Tell git you want to ignore them? But you probably should track .yarnrc.yml.
    – jonrsharpe
    Commented Jun 12 at 11:56
  • why should I add something to gitignore that should not be there in the first place? my team members don't have this issue, why should I polute gitignore just because yarn does weird things? moreover, why my question is downgraded? is it a stupid question? because i've tried everything to avoid that yarn polutes my commits Commented Jun 13 at 8:31
  • 1
    Maybe you're using different Yarn versions. Maybe they have higher-level .gitignore files (stackoverflow.com/q/7335420/3001761). Maybe something else - you're in a far better position to investigate that than any of us are.
    – jonrsharpe
    Commented Jun 13 at 8:33
  • @Albert Maybe because it is not answerable here, then? You should ask yarn developers, why they generate such files in an install, not us. If yarn documentation, which I added to my answer, is not sufficient for you.
    – Jerry
    Commented Jun 13 at 12:42
  • these files are not always generated, for some colleagues it does not happen, it's an issue that we have in the team. But I guess it's a bad question, we must be stupid in our team. Keep downvoting, stackoverflow is an amazing place to ask questions and super useful nowadays Commented Jun 17 at 6:09

1 Answer 1

-1

Add the folder and the file to .gitignore:

.yarn/
.yarnrc.yml

That way will git not show these items as changed/added.
But in the documentation is stated, that .yarnrc.yml file should be included in your project, as well as some .yarn/ subdirectories. I suggest you read it, there is also explanation of individual generated files.

Check out other resources about ignoring files and directories:
How to ignore certain files in Git
How to write .gitignore so that it only includes YAML files and some specific files?
Yarn v2 gitignore

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