Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

sandersjj's avatar

Laravel Forge pushing to master gives an error

Hello Everyone,

I am trying to push my master branch which will trigger forge to deploy. However Forge gives me this error:

Sun Jan 13 20:42:18 UTC 2019
From bitbucket.org:xxxxxxxx/yyyyy
 * branch            master     -> FETCH_HEAD
   7e32660..310a40a  master     -> origin/master
error: Your local changes to the following files would be overwritten by merge:
    public/js/app.js
    public/mix-manifest.json
Please, commit your changes or stash them before you can merge.
Aborting
Updating f7ea17b..310a40a

Now I don't have anything special in my build script:

cd /home/forge/xxxxxxx.nl
git pull origin master
composer install --no-interaction --prefer-dist --optimize-autoloader
echo "" | sudo -S service php7.1-fpm reload

if [ -f artisan ]
then
    php artisan migrate --force
fi

So I am not sure how I should solve this. If i do git status on my master branche i get that there are no changes. So what should i do now?

0 likes
4 replies
Cronix's avatar
Cronix
Best Answer
Level 67

Are you sure you didn't run npm run production or anything on the production box?

sandersjj's avatar

Actually I did. I did a git stash on my server and then I could deploy it.

So then when should I run npm production in order to prevent this happening again?

Cronix's avatar
public/js/app.js
public/mix-manifest.json

Those files shouldn't be tracked by git then. Add them to your .gitignore and remove them from git.

git rm --cached public/js/app.js
git rm --cached public/mix-manifest.json

Now you won't get the error on production when the files change (which is what's causing the actual problem) after you run npm for production.

Or, alternatively, keep them in git and run npm run production on your dev box and commit the compiled assets so the compiled versions are in git, and then don't run it on production.

trevorpan's avatar

@CRONIX - Hi, after you run 'npm run production' and pushed to github I ran composer install, to resume developing on my local machine.

Is this how it's done?

I felt like it was inefficient run the commands in the laravel deploy docs, and then 'npm run production', have all those packages deleted and the reinstall them. Just want be sure that is the correct way.

Thank you`

Please or to participate in this conversation.