Dploy Error Bad Object How To Resolve

dploy, is a really useful way to deploy websites using FTP/SFTP and git from the command line.

Error: Command failed: /bin/sh -c git diff … fatal: bad object

While setting up your local working environment to use dploy, you may encounter a stubborn error related to a supposed bad object resulting from when dploy attempts to perform a git diff.

Connecting to ftp.my-development-server.com...
Checking revisions...
Checking diffs between [116fc716b06c4120bd0fda0e03331e72b481d432] > [216fc716b06c4120bd0fda0e03331e72b481d432]
An error occurred when retrieving the 'git diff --name-status 116fc716b06c4120bd0fda0e03331e72b481d432 216fc716b06c4120bd0fda0e03331e72b481d432' { [Error: Command failed: /bin/sh -c git diff --name-status 116fc716b06c4120bd0fda0e03331e72b481d432 216fc716b06c4120bd0fda0e03331e72b481d432
fatal: bad object 116fc716b06c4120bd0fda0e03331e72b481d432
  killed: false,
  code: 128,
  signal: null,
  cmd: '/bin/sh -c git diff --name-status 116fc716b06c4120bd0fda0e03331e72b481d432 216fc716b06c4120bd0fda0e03331e72b481d432' }

This might happen if you attempted to set it up, failed for some reason, and then start over.
Whatever the reason, do not jump to the conclusion that there is actually a bad object in the repo. Often, when git encounters an object it does not expect, it throws a bad object error.

How to tell

First check to see if there is a residual .rev file on the server dploy id attempting to “push” to. There is a good chance of this being the case if you have made more than one attempt to install dploy.

The way to check is simple to open the .rev file that is sitting on the remote sever and if it contains the hash if the “bad object”.

Take note of the bad object

In this case the error says:
fatal: bad object 116fc716b06c4120bd0fda0e03331e72b481d432

Open the remote .rev file

NOTE: Since this is a file name that starts with a dot “.”, it is a “hidden” file. You will need to make sure your FTP browser is allowing you to see hidden files.
Screenshot 2015-03-05 10.27.28
You can find the .rev file in whatever directory you are attempting to “push” to on the remote server

Take note of the object hash in the remote .rev file

It will not be hard to find as the .rev file only contains a single object hash.

How to resolve the issue

If the hash is the same as the one in the error message (ie. 116fc716b06c4120bd0fda0e03331e72b481d432), then delete the remote .rev file. Dploy will create another one.

I hope this was helpful to you. If so, please comment or share.

Leave a Reply

Your email address will not be published. Required fields are marked *