git pull error: “error: insufficient permission for adding an object to repository database .git/objects”

Today, when I was pulling changes from a remote repository, the error busted out:

error: insufficient permission for adding an object to repository database .git/objects

The error message indicates the problem itself, current user does not have insufficient permission to add objects to .git/objects folder.

If you’re familiar with Linux ownership and permission, it’s so easy for you. In case of not, read the following topic, it’s really interesting though: Linux Ownership and Permissions

So, we need to grant permission to the folder. We have 2 approaches:

1. Change owner of the folder and its sub-folders to current user

$chown [current-user-name]:[group-name] .git/objects -R

In my case:

$chown ducfilan:root .git/objects -R

Note: current username can be gotten from:

$echo $USER

2. Chmod the folder and its sub-folders to grant write permission to the current user

If you execute the below command, you will see your permission to the objects folder:

$ll .git | grep objects
$ll .git/objects

If you faced with the mentioned problem, you will see that you don’t have permission to that folder. Depends on your decision, you can grant which permissions to the folder you want. Maybe:

$chmod 766 .git/objects -R

Now you are ready to pull it down.

P/s: Personally, I recommend the first approach, it’s a natural and secure way.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s