2

I followed this tutorial: on setting up a git deployment process to an ec2 instance.

I carefully went through all the steps of ssh'ing into the ec2 machine with a ~/.ssh/ host in the config file. Creating the bare git repo. Adding the post-receive hook script and so on.

Locally, I make some changes, commit.
Then I added the ec2 repo with git remote add deploy ec2:/home/ec2-user/ab-site (ab-site is the bare git repo I just initialized -- and ec2 is the ssh alias I set up locally in the ~/.ssh/config file).

Yet When I go to push with git push deploy +master:refs/heads/master

I get a bunch of errors.

warning: core.bare and core.worktree do not make sense remote:
warning: core.bare and core.worktree do not make sense remote: error:
insufficient permission for adding an object to repository database
./objects remote: fatal: failed to write object error: unpack failed:
unpack-objects abnormal exit

So I'm curious what I should look at next to fix this.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
Alex Bollbach
  • 4,370
  • 9
  • 32
  • 80
  • "insufficient permission for adding an object to repository database" — this part of the error message is telling. I would start by checking to make sure that your ec2 user (in this case probably `ubuntu`) has permissions to write to the repository. – Ryan Atallah Jul 02 '17 at 05:18

2 Answers2

0

core.bare and core.worktree do not make sense

That is a warning which, since Git 2.5+, is fixable. If that warning is on the remote side, that means core.bare was set to true, while worktree was set as well.

The usual fix is git config --unset core.worktree but in your case, from that comment

with bare=false it works OK.

Then you can double check the permission issue.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    My understanding of all this was that I was creating a `bare` git repo as these are the only kinds of repos that one can push to. Since my goal is to push my website to my server and run a deployment script on the push receive hook, this seemed to make sense. But now I should set bare equal to false? Sure, I can take the advice but I have no understanding of why. – Alex Bollbach Jul 02 '17 at 17:32
  • @AlexBollbach I agree: I would unset the worktree instead, and keep the bare nature. Note that, since Git 2.3, you can push too non-bare repos, as I mention in https://stackoverflow.com/a/44406425/6309 (see the links there) – VonC Jul 02 '17 at 18:35
0

Your problem contains warnings and errors

  1. Warning of

    warning: core.bare and core.worktree do not make sense remote: warning: core.bare and core.worktree do not make sense remote: error:

Solution

Bare repository are read only repository. The most common use case for bare repo is to create a remote central Git repository ,

so git prints the "fatal: core.bare and core.worktree do not make sense" error message. Therefore, you need to set bare = false in the repo's config file.

cd barerepo
git config --bool core.bare false
git config --path core.worktree /var/www/mywork
  1. Error of

    Insufficient permission for adding an object to repository database

    ./objects remote: fatal: failed to write object error: unpack failed: unpack-objects abnormal exit

Solution

cd repository/.git

sudo chmod -R g+ws *
sudo chgrp -R mygroup *

git config core.sharedRepository true
Chintan7027
  • 7,115
  • 8
  • 36
  • 50