0

I'm trying for the first time to set up GIT on a VPS following this tutorial. Part of the instructions are:

cd /var
mkdir repo && cd repo
mkdir site.git && cd site.git
git init --bare

However, on mkdir repo I get cannot create directory ‘repo’: Permission denied. I'm logged into the VPS as a user with sudo rights. How can I find out the cause of the problem? I'm really new to this so am not sure what to report here.

Update: After solving the above by adding sudo to the command, I got a permission error on git push live master:

Counting objects: 709, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (665/665), done.
Writing objects: 100% (709/709), 103.57 KiB | 0 bytes/s, done.
Total 709 (delta 368), reused 0 (delta 0)
remote: fatal: Unable to create temporary file '/var/repo/site.git/./objects/pack/tmp_pack_XXXXXX': Permission denied
error: unpack failed: index-pack abnormal exit
To ssh://username@VPS_IP_ADRES/var/repo/site.git
 ! [remote rejected] 3.7-advanced-testing -> 3.7-advanced-testing (unpacker error)
etc.

I did skip a few steps of the tutorial because I already have GIT completely set up in Cloud9IDE (which I use for writing my app). This works and I can push to Heroku, which I now am trying to replace with a VPS. So what I have done from a situation with a working GIT: I did the four steps mentioned above, while logged into the VPS as superuser. Then, while logged in at Cloud9, I did git remote add live ssh://username@VPS_IP_ADRES/var/repo/site.git. And then git push -u live --all, which gave me the errors above. Any idea about there cause?

1

That tutorial is assuming you have superuser rights, so just use sudo su before you start running commands, or insert sudo before all the commands that require elevation.

| improve this answer | |
  • Thanks William, that worked: sudo mkdir repo. Im going to read up on what it means exactly to have superuser rights. – Nick Jul 20 '15 at 16:11
  • I was hoping to ask a follow up question, which I added to my OP (see update). – Nick Jul 20 '15 at 16:23
  • Did you log in through SSH as a normal user or as root? – william Jul 20 '15 at 16:26
  • Actually, after the first four steps I logged out from the VPS. I am then still logged in in Cloud9. In Cloud9 I did: git remote add live ssh://username@VPS_IP_ADRES/var/repo/site.git and git push -u live --all. – Nick Jul 20 '15 at 16:27
  • I'd say either SSH in as root, or instead of using /var stick the repo in the Cloud9 home directory (/home/Cloud9/var/repo for example). You're getting errors because the Cloud9 user doesn't have permission to modify subdirectories in /var. – william Jul 20 '15 at 16:31
1

you need root privilege so you have to add sudo :

cd /var
sudo mkdir repo && cd repo
sudo mkdir site.git && cd site.git
sudo git init --bare
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.