I’m trying to setup a Git repo on my local machine for work that is being done on my local machine – no remote anything.
I’ve setup remote repos several times but it seems the steps I take locally always end up with errors.
I have 2 directories: /home/rico/project and /home/git/project_repo
I’ve created the git user to manage all my git repos (I expect to have dozens).
From /home/rico/project as the rico user I do the following command:
rico@verbal:~/project$ git init
Initialized empty Git repository in /home/rico/project/.git/
From /home/git/project_repo as the git user I do the following:
git@verbal:~/project_repo$ git --bare init
Initialized empty Git repository in /home/git/project_repo
Now I go back to my project and add files.
rico@verbal:~/project$ git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# .project
# .pydevproject
# inc/
# manage.py
# rocksolidbox/
# rsb/
# templates/
rico@verbal:~/project$ git add inc media rocksolidbox/ rsb/ templates/
rico@verbal:~/project$ git commit -a -m "Initialize the project."
At this point I get the normal commit message – 23 files changed, 989 insertions(+) etc.
Now, I want to push this to the project_repo folder.
rico@verbal:~/project$ git remote add origin /home/git/rocksolidbox/
rico@verbal:~/project$ git push -u /home/git/rocksolidbox/ master
But receive the following error:
Counting objects: 31, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (26/26), done.
error: insufficient permission for adding an object to repository database ./objects
fatal: failed to write object
Writing objects: 100% (31/31), 12.24 KiB, done.
Total 31 (delta 2), reused 0 (delta 0)
error: unpack failed: unpack-objects abnormal exit
To /home/git/project_repo/
! [remote rejected] master -> master (n/a (unpacker error))
error: failed to push some refs to '/home/git/project_repo/'
Clearly this is a permissions error. I’ve tried to do the push such as:
rico@verbal:~/project$ git push -u git@verbal:/home/git/rocksolidbox/ master
Or even using my local IP:
rico@verbal:~/project$ git push -u git@192.168.1.101:/home/git/rocksolidbox/ master
It asks for a password, which I know I’m supplying correctly and I continually get the message Permission denied, please try again.
I just want to be able to push my project to my project_repo. What am I doing wrong in this setup?
Ok, I’ve figured out a way around the permissions problem. Basically do this:
Then I can do the following commands with my
project:Then to clone the project elsewhere simply do:
And you’re golden.
Now, my question remains…is this the best way of handling the permissions problem? I don’t really like the idea of giving
777to anything. Should I putgitandricoin the same group and do775instead?Any suggestions?
EDIT1:
Putting
gitandricoin the same group and doing775did not help. It works fine with777but I don’t like this solution.