See the Questions & Answers section of the documentation. It has changed several times, so for the most up to date answer just click that link!
But in the StackOverflow spirit of “no link-only answers” here’s a snapshot:
Which files should be gitignored?
If you’re using Zero-Installs:
.yarn/* !.yarn/cache !.yarn/patches !.yarn/plugins !.yarn/releases !.yarn/sdks !.yarn/versions
If you’re not using Zero-Installs:
.pnp.* .yarn/* !.yarn/patches !.yarn/plugins !.yarn/releases !.yarn/sdks !.yarn/versions
Note that, of the paths you mention, only .yarn/releases
should not be in .gitignore
.