When trying to deploy code, you get the following error:
There are uncommitted changes, commit or stash these changes before deploying
Ensure that your Git directory is clean before deploying. BLT should print a list of all dirty files to help you debug. If deploying locally, this is simply a matter of committing the changes. If deploying via CI, you'll need to determine what might be causing these files to change during the test process.
Before deploying code, BLT ensures that the source directory is clean according to Git. This ensures that any changes being deployed are captured in your source repository. This is especially important in a CI environment in order to ensure that nothing during the testing process itself modified the codebase in way that could lead to undefined or undesirable behavior once deployed. For instance, this prevents the testing process from changing database credentials that then get deployed to a production environment.
A few examples of what can cause files to change during the deploy process and how to troubleshoot:
- If you have defined frontend build steps that call
package-lock.jsonmay be modified during deployments. Try using
npm ciinstead (see Frontend docs for details). Warning:
npm ciis not present in older versions of npm.
- Ensure that the files' permissions are committed properly (as git will track a file as
Mif the diff is the same, but permissions differ)
- Try replicating the CI process locally by running the same commands (visible in the CI logs), such as
blt tests:all. If these change files locally, you should determine if these changes need to be committed or whether your test scripts need to be adjusted to avoid creating changes.
blt doctorlocally to ensure that there are no problems such as missing settings file includes.
- See this issue for additional documentation and solutions.
In an emergency, you can disable this check by passing the
--ignore-dirty flag to
blt deploy, but this is strongly discouraged as it may conceal deeper issues with your codebase.