Problems after several months with Laravel Forge
Asked by Gioacchino Poletto:

Laravel Forge manages auto-deploys of a Laravel app, on every push to the repository.  
I've never had a problem, until we switched servers on DigitalOcean.  
Following this I had to create a new server on Forge and link it to the previous server's repository.

The local code has remained the same, as has the remote code.  
I just changed the server to Forge, and liked it to Bitbucket (as usual).  

I have started to receive error like this:

```
on Feb 19 14:21:47 UTC 2023 
From bitbucket.org:XXX/XXX-app 
* branch master -> FETCH_HEAD 
35e743e..aa18902 master -> origin/master 
error: Your local changes to the following files would be overwritten by merge: 
xxx.php
Please commit your changes or stash them before you merge. 
Aborting 
Updating 3856d4a..aa18902
```

or this:

```
Sun Feb 19 14:21:47 UTC 2023 
From bitbucket.org:XXX/XXX-app * branch master -> FETCH_HEAD 
error: cannot lock ref 'refs/remotes/origin/master': is at aa18902c3d1b2288a290f6c089be12e457205b77 but expected 35e743e53101820a74e4d903e12f14c481adc2d1 
! 35e743e..aa18902 master -> origin/master (unable to update local ref)
```

I have try to reset my local git with:

```
git reset --hard

git clean -df
```

as suggested on Forge and inside various web blogs \& articles without solutions.  

Is there a way to align my local version, what is present on Bitbucket and the Forge server (on DIgitalOcean) ?  
Many thanks for your help, very appreciated.


Answers:
author: Theodora Boudale
body: Hi [@Gioacchino Poletto](/t5/user/viewprofilepage/user-id/4655442),

What command is executed when you get the errors you posted here? Is it a git pull or git fetch?

And where are the commands executed? On a clone of the repo on the Forge server? Or on your local repo? Or is one of them on the Forge server and the other one on your local repo?

The error in the first output you posted here indicates that there are changes in the working directory of that specific clone that have not been committed yet. You can either commit them (so that you don't lose them), or if you want to discard the changes that haven't been committed, run **git reset --hard**.

The second error is different. One possible cause for this error is having in the clone two branches with the same name and different capitalization. You can use the command **git branch** in the clone to see if there is perhaps a second branch named master with different capitalization.

If this is not the case, you can try removing the local ref refs/remotes/origin/master by running

```
git update-ref -d refs/remotes/origin/master
```

and then do a **git pull** or **git fetch** again. This will not delete anything on the Bitbucket repo, it will only remove the local ref, which should be fetched again once you run git fetch or git pull.

Kind regards,  
Theodora

comments: author: Gioacchino Poletto
body: Dear [@Theodora Boudale](/t5/user/viewprofilepage/user-id/818086) ,  
many thanks for your reply, much appreciated!

I have try also this solution, but finally I have solved the problem stopping and restarting Forge Quick Deploy.

Probably, during the first boot you had saved two auto deploy settings and each push generated 2 deploy instances.


author: Theodora Boudale
body: Thank you for the update [@Gioacchino Poletto](/t5/user/viewprofilepage/user-id/4655442), it's good to hear that you resolved the issue.

Please feel free to reach out if you ever need anything else!


Tags: cloud

digital-ocean

forge