Issue¶
Getting the following error during the BLT, Code Studio, ACLI or Pipelines build process shows that you have uncommitted changes but when you check your branch everything has been committed and you do not see any uncommitted files.
ACLI
In PushArtifactCommand.php line 100:
[Acquia\Cli\Exception\AcquiaCliException]
Pushing code was aborted because your local Git repository has uncommitted
changes. Please either commit, reset, or stash your changes via git.
BLT
[Exec] Exit code 1
[error] There are uncommitted changes on the source repository (listed above). Commit, stash, or remove these changes before deploying, or use the --ignore-dirty flag.
Code Studio
You have committed files or directories that Acquia recommends gitignoring.
Please do not commit any of the following files or directories:
vendor, node_modules, docroot/composer.json, docroot/libraries, docroot/core, docroot/modules/contrib, docroot/themes/contrib, docroot/profiles/contrib
Cause¶
This is happening because a lot of these directories are committed in your codebase currently when they should be
gitignored so
composer can add them during the build for you. This is relevant because when you pull your repository to a new local folder and run
composer install you can see several files are changing when running
git status.
How to identify and get an extra output to see the uncommitted files:¶
To get this extra output, you can add a before_script to the stage and output git status
and git diff
. Basically, you would just need to append this to the end of your .gitlab-ci.yml
(Code studio) or equivalent of any CI/CD build process.
"Create artifact from branch":
before_script:
- git status
- git diff
Resolution¶
- Clone the repo in a new folder. You should not have core directory and of course vendor folder and others.
- Remove the docroot/core from your .gitignore. Commit your change using Git.
- Remove the actual folder and commit your change using Git.
- Add the docroot/core back to the .gitignore. Commit your change using Git.
The bottom line, you should not have the core directory in your repository when you are using push build artifact. Push build artifact will generate them for you. Use this sample for your gitignore:
- https://github.com/acquia/drupal-recommended-project/blob/master/.gitignore
This is an example for like `core` directory. You should check the other file and folder that is in the .gitignore. You should do the same thing for the other files/folders in the .gitignore to resolve this issue.
Example recommended .gitignore file:
- https://github.com/acquia/drupal-recommended-project/blob/master/.gitignore
Example for clarification:
For example if you want to ignore file/folder X in your repo, you will need to add the file/folder X to the .gitignore. This means that you want to ignore the future changes in this folder/file. In other words, you are not ignoring the past changes. Basically if you have the file/folder X in your repository, it will stay in your repository even you add it to .gitignore.
Related Content¶
"
Should I commit the dependencies in my vendor directory?"