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

MB's avatar
Level 2

Getting error when trying to Deploy github changes

Hi,

I made some updates to my code, pushed to github and then went to Deploy from Forge. Getting this error (from Forge):

 * branch            master     -> FETCH_HEAD
error: Your local changes to the following files would be overwritten by merge:
	.env
Please commit your changes or stash them before you merge.
Aborting

I already added .env to my .gitignore file - after getting the error. Then did a new push and it tells me that everything is up to date now.

git status
On branch master
Your branch is up-to-date with 'origin/master'.

nothing to commit, working tree clean

Still getting the error though. Why is that?

git merge
Already up-to-date.
0 likes
10 replies
MB's avatar
Level 2

Thanks for the reply, @armancodes I already did that, getting same error:

Local machine:

git push
...
Everything up-to-date

Laravel Forge:

 * branch            master     -> FETCH_HEAD
error: Your local changes to the following files would be overwritten by merge:
	.env
Please commit your changes or stash them before you merge.
Aborting
MB's avatar
Level 2

Hi @armancodes Do you know if I can connect to my DigitalOcean server from within Forge? Or should I do this on the DigitalOcean website?

MB's avatar
Level 2

@armancodes Yes, i have added my github account to Forge. It's Forge that display that error.

 * branch            master     -> FETCH_HEAD
error: Your local changes to the following files would be overwritten by merge:
	.env
Please commit your changes or stash them before you merge.
Aborting
Updating 3952ad4..

I have SSH into the Forge server (digitalocean), using the console from DigitalOcean website. Getting this error (I can't mark/copy text in the console):

https://imgur.com/a/i0t6AVp

Should I do "git checkout .env"?

drewdan's avatar
drewdan
Best Answer
Level 15

Is your env file different from the one in your git repo?

I would run git rm --cached to make sure the gitignore does ignore the changes to the env file

MB's avatar
Level 2

@drewdan , Both my local computer and the server does not accept that command. It just keep posting the help section... ? The .env file is probably different. It does not exist in the repo anymore though.

(master) $ git rm --cached
usage: git rm [<options>] [--] <file>...

    -n, --dry-run         dry run
    -q, --quiet           do not list removed files
    --cached              only remove from the index
    -f, --force           override the up-to-date check
    -r                    allow recursive removal
    --ignore-unmatch      exit with a zero status even if nothing matched

Seems the flag is correct though. Not sure why nothing happens when I type it.

drewdan's avatar

Run that on your server and then git pull

MB's avatar
Level 2

It told me no file existed, when running that command (on the server).

I noticed the env file existed on the server, so deleted that one and ran the Deploy tool in Forge, some weird message appeared.

My solution: Uninstall Repository, delete the database and then run it again. It's a fresh server, so no harm done.

Have a feeling I did 10+ things wrong here though :/ Need to learn more about git i pressume, have just used it as a backup tool until now.

Anyway, thanks for the help guys :)

MB's avatar
Level 2

Just did a small test. Created a new file on my computer. Pushed to the repo. Deployed from Forge and it worked flawless again.

I really messed up that .env file :p

Please or to participate in this conversation.