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

WallyJ's avatar

Forge error when Deploying from Github branch

I set up my connection between my Forge account and my DigitalOcean server. I have deployed code twice. After a lot more code changes/additions and working with another developer on the project, I am receiving an error on deployment on Forge:

Sun Dec 5 01:54:12 UTC 2021 Warning: Permanently added the RSA host key for IP address '140.82.112.4' to the list of known hosts. error: insufficient permission for adding an object to repository database .git/objects fatal: failed to write object fatal: unpack-objects failed

I have read a couple of articles about changing permissions in a git folder, but I can't find that folder on my digitalocean droplet.

0 likes
11 replies
Tray2's avatar

Your git directory is usually prefixed with a dot . that makes the file hidden on *nix operating systems.

I suggest you try ls -la and it should be visible to you, if it isn't it doesn't exist.

WallyJ's avatar

@Tray2 I found the git directory, but didn't see any glaring issues. I'm stuck at this point. Not sure what to do next.

WallyJ's avatar

Thanks. There is a gitconfig directory, but not a git directory. Not sure what to do next.

Is the .git directory supposed to be in the root or in the home directory?

Tray2's avatar

@WallyJ The .git directory should be in your projects root folder.

So if you hace something like. /Users/<your_user>/code/my-nifty-laravel-project the .git should be in the my-nifty-laravel-project .

In my one of my projects it looks like this

 #pwd
/Users/tray2/code/mb2
#ls -la
total 2240
drwxr-xr-x   32 tray2  staff    1024  2 Dec 18:35 .
drwxr-xr-x   14 tray2  staff     448  4 Dec 17:51 ..
-rw-r--r--    1 tray2  staff     258 26 Okt 17:20 .editorconfig
-rw-r--r--    1 tray2  staff     999  2 Dec 18:35 .env
-rw-r--r--    1 tray2  staff     899 26 Okt 17:20 .env.example
drwxr-xr-x   12 tray2  staff     384  5 Dec 07:58 .git
-rw-r--r--    1 tray2  staff     111 26 Okt 17:20 .gitattributes
-rw-r--r--    1 tray2  staff     207 26 Okt 17:20 .gitignore
drwxr-xr-x   17 tray2  staff     544  6 Dec 21:35 .idea
-rw-r--r--    1 tray2  staff   27178  6 Dec 05:32 .phpunit.result.cache
-rw-r--r--    1 tray2  staff     194 26 Okt 17:20 .styleci.yml
-rw-r--r--    1 tray2  staff    3999 26 Okt 17:20 README.md
Sinnbeck's avatar

@WallyJ at least you have it in git. You should be able to git clone into a new directory and copy over the env file + any storage files. Then you can change the webserver to point to the new directory

WallyJ's avatar

@Tray2 Found the directory. Not sure what to do with it. Seems to be a permissions issue. Not sure what to change so it will deploy properly.

WallyJ's avatar

@Sinnbeck Thanks, but I would rather fix the existing directory if possible. It worked before. Not sure what changed. The SSH keys are already set up.

Sinnbeck's avatar

@WallyJ as you found the folder, there is no need to. What exact command triggers the error? Almost sound like forge is trying to push?

Tray2's avatar

@Tray2 Found the directory. Not sure what to do with it. Seems to be a permissions issue. Not sure what to change so it will deploy properly.

@WallyJ Are we talking about the storage directory here or some other directory?

My storage directory has the following permissions

drwxr-xr-x   5 tray2  staff     160  8 Dec 21:30 storage

That is the same as 755.

If you don't have that permissions you can chmod it like this

sudo chmod -R 755 storage

OhhDeer's avatar

Just following up from this, you may find the permissions. based answer on StackOverflow here: https://stackoverflow.com/a/6448326/11405055 useful. Ensure all the files and folders inside the directory are owned by forge and the forge group (unless you are using user isolation, in which you should use the user you setup when creating the site) - Below is an example of one of our directories, where the site user is kling

drwxrwxr-x  13 kling kling   4096 Dec  6 09:31 .
drwxr-xr-x+  9 kling kling   4096 Dec  6 09:31 ..
-rw-rw-r--   1 kling kling    258 Dec  6 09:31 .editorconfig
-rw-rw-r--   1 kling kling   1142 Dec  6 10:00 .env
-rw-rw-r--   1 kling kling    939 Dec  6 09:31 .env.example
drwxrwxr-x   8 kling kling   4096 Dec  8 13:15 .git
-rw-rw-r--   1 kling kling    111 Dec  6 09:31 .gitattributes
-rw-rw-r--   1 kling kling    220 Dec  6 09:31 .gitignore
-rw-rw-r--   1 kling kling    194 Dec  6 09:31 .styleci.yml
-rw-rw-r--   1 kling kling   3964 Dec  6 09:31 README.md
drwxrwxr-x   8 kling kling   4096 Dec  6 09:31 app
-rwxrwxr-x   1 kling kling   1686 Dec  6 09:31 artisan
WallyJ's avatar

Seems that I got the folder permissions issue fix, and now when I deploy it gives me this error:

Fri Dec 10 00:39:26 UTC 2021 Host key verification failed. fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

It gives me 3 suggested fixes:

Solutions found

  1. The repository may be invalid or the server owner's source control credentials may not have permission to access it. Please review the Git Remote on the Site Details section. Alternatively, try to refresh the source control token.

  2. Forge may not be an approved integration. If the repository is within a GitHub organization and is private, please ensure that Forge is an approved integration.

  3. The server's public key may need to be added to the server owner's source control provider. Typically, this key will automatically be added to the owner's GitHub account. However, please ensure the server's public key available within the server's "Meta" tab exists in the source control account of the server owner.

I have done number one and two and I added the key, as suggested by #3, however, in Github it says "There are no SSH keys associated with your account."

But if I try to add the key again it says "Key is already in use". So I'm sure it's an SSH key issue but I'm not sure what key is supposed to go from where to where. I thought I did that already.

I'm thinking about remaking the droplet and choosing the ssh key from the beginning and hoping the auto setup takes care of it, but I'd rather not have to point my domain to a new IP and wait for it to propogate, etc.

Please or to participate in this conversation.