Skip to content
CODE THE PIXEL
Misc

Git Pull Error in cPanel

Asyraf Wahi Anuar 2 min read

Solving cPanel Git pull error by using the composer install no dev optimized autoloader

When using Git to sync your project, and it involves the composer update, make sure you are not running the composer update in the cPanel terminal. Running composer update directly on your hosting server changes the composer.lock file, which then causes Git to flag it as different from the repository version. A good practice is to only run composer update on your local machine, commit the updated files (composer.json and composer.lock), then push and pull them on your hosting environment. This ensures consistency and avoids deployment surprises.

Tips: If you ever get into a similar situation again, remember you have the option to commit, stash, or reset the file depending on what you want to keep.

The local workflow

  1. Always run composer update locally first (This will update composer.lock with the latest versions)

  2. Commit composer.json and composer.lock together in Git

  3. Deploy only after syncing everything to the repository

Deploy and install dependencies on the server

  1. SSH into your web server and navigate to your project folder, or use Terminal if available

  2. Run git pull origin your-branch to sync the latest changes, or use Git Version Control in cPanel

  3. Then, install the dependencies using:

Terminal
composer install --no-dev --optimize-autoloader

This ensures your vendor folder is updated based on the locked versions in composer.lock.

By following this workflow, your production environment stays consistent with your local setup, and you avoid unexpected dependency changes.

Did this tutorial help?

0 readers found this helpful

Comments

No comments yet. Questions about this tutorial are welcome here: the answer helps the next reader too.

Leave a comment

Markdown works: `code`, ``` blocks, **bold**, links.

First comments are reviewed before they appear.

Tools & Software

Upgrade PHP and Apache in Laragon 6: A Step-by-Step Tutorial

Upgrading PHP and Apache in Laragon can enhance your development environment significantly, providing access to the latest features and improvements. This step-by-step tutorial will guide you through the process, ensuring a smooth transition while preserving your existing projects

4 min read

Misc

Git Tutorial: Uploading a Project to GitHub and Collaborating with Others

Version control is essential for developers, and Git is a powerful tool that helps manage project changes efficiently. GitHub, a popular platform built on Git, not only hosts repositories but also facilitates collaboration among developers worldwide. In this tutorial, we will explore the process of...

4 min read