should .nx be in git ignore? (nx monorepo)

254 Views Asked by At

I recently upgraded my Nx monorepo workspace from v13 to v16 using the nx migrate command and did the required modifications manually. The command added an .nx folder with a cache subfolder:

enter image description here

The nx migrate command didn't add the cache folder to .gitignore. While I don't think local caches should be version controlled and committed to git, the folder contains other files with meaningful names (nxdeps.json, file-map.json, etc.) that I'm not sure if they are mandatory for the upgraded nx version.

Should I add .nx/cache to my .gitignore?

1

There are 1 best solutions below

0
Lorraine Ram-El On

Yes, after continuing the upgrade from Nx v16 to v17, the migration tool automatically added .nx/cache to .gitignore

enter image description here

However, if you've already committed file(s) from .nx/cache, remember to remove it from Git's tracking system by running:

git rm -r --cached .nx/cache
git commit -m "Stop tracking .nx/cache directory"

otherwise just adding the folder to .gitignore won't do the work.