Search code examples
gitmonorepopnpm

Why `git add . ` command sometimes doesn't adds lockfile to staging area?


When I do git add . in a monorepo with pnpm, sometimes it doesn't include lockfile to staging area.

Picture of source control after I do git add .


Solution

  • Make sure to run the git add . from the root of the project such that git can parse through the file tree and stage the changes.

    Make sure to not have lock file to the .gitignore file which git add commands respect when staging changes.

    Use git add -A instead of git add . to add all the changes introduced after the recent commit in the repository instead of just staging changes in the current directory.