rjd rjd - 1 year ago 253
Git Question

fatal: Unable to create temporary file '/home/username/git/myrepo.git/./objects/pack/tmp_pack_XXXXXX': Permission denied

I have been having trouble with this error message and I don't understand the proper solution to fix it or go about debugging it. I have googled the error in various forms but no real solution has presented itself. I am assuming it's an issue with permissions but I don't really know how to check or what I should check for.

I have a server running Ubuntu 11.10 and I'm basically trying to make the initial commit to my git repo from my development machine. I'm running as root. Should I be running as the user?

Repo creation on server:

$ cd /home/username/git
$ mkdir myrepo.git
$ cd myrepo.git/
$ git --bare init

Repo creation on development machine:

Goto rails project directory first
$ git init
$ git add .
$ git commit -m "initial commit"
$ bundle pack
$ git add Gemfile.lock vendor/cache
$ git commit -m "bundle gems"
$ git remote add origin ssh://username@server.com/home/username/git/myrepo.git
$ git push origin master


fatal: Unable to create temporary file '/home/username/git/myrepo.git/./objects/pack/tmp_pack_XXXXXX': Permission denied
error: pack-objects died of signal 13
error: failed to push some refs to 'ssh://username@server.com/home/username/git/myrepo.git'

My .git/config file:

repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
[remote "origin"]
url = ssh://username@server.com/home/username/git/myrepo.git
fetch = +refs/heads/*:refs/remotes/origin/*

Similar question:
How do I do an initial push to a remote repository with Git?

Answer Source

It sounds like you have file in the git repo owned by root. Since you're ssh'ing in as 'username' to do the push, the files must be writable by username. The easiest thing is probably to create the repo as the user, and use the same user to do your pushes. Another option is to create a group, make everything writable by the group, and make your user a member of that group.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download