I have a project on my vagrant machine that I would like to push into my github repository. But I cannot add objects without using sudo
.
- I have initialized git
vagrant@vagrant:/vagrant/testDir$ git init Initialized empty Git repository in /vagrant/testDir/.git/`
- After that if I run the command to add contents
Then I am getting this error:vagrant@vagrant:/vagrant/testDir$ git add .`
error: insufficient permission for adding an object to repository database .git/objects
error: file1: failed to insert into database
error: unable to index file file1
fatal: adding files failed
Although I can run the command without any errors if I run with sudo
, i.e., sudo git add .
.
I have confirmed the permission inside the project, and they are are okay:
vagrant@vagrant:/vagrant/testDir$ ls -al
total 0
drwxr-xr-x 1 vagrant vagrant 160 Dec 23 10:33 .
drwxr-xr-x 1 vagrant vagrant 160 Dec 23 10:33 ..
drwxr-xr-x 1 vagrant vagrant 352 Dec 23 10:33 .git
-rw-r--r-- 1 vagrant vagrant 0 Dec 23 10:33 file1
-rw-r--r-- 1 vagrant vagrant 0 Dec 23 10:33 file2.txt
I have ubuntu 18.04 on my vagrant machine running on macOS High Sierra. Vagrant = 2.2.2 Virtual box = 6.0.8 r130520
Could you please help me out?
Update 1
Also, the permission on .git/
directory are fine
vagrant@vagrant:/vagrant/testDir/.git$ ls -al
total 12
drwxr-xr-x 1 vagrant vagrant 320 Dec 23 10:52 .
drwxr-xr-x 1 vagrant vagrant 160 Dec 23 04:12 ..
-rw-r--r-- 1 vagrant vagrant 23 Dec 23 04:12 HEAD
drwxr-xr-x 1 vagrant vagrant 64 Dec 23 04:12 branches
-rw-r--r-- 1 vagrant vagrant 111 Dec 23 04:12 config
-rw-r--r-- 1 vagrant vagrant 73 Dec 23 04:12 description
drwxr-xr-x 1 vagrant vagrant 416 Dec 23 04:12 hooks
drwxr-xr-x 1 vagrant vagrant 96 Dec 23 04:12 info
drwxr-xr-x 1 vagrant vagrant 160 Dec 23 04:12 objects
drwxr-xr-x 1 vagrant vagrant 128 Dec 23 04:12 refs
Update 2
The permission inside the .git/objects
directory are also okay.
vagrant@vagrant:/vagrant/testDir/.git/objects$ ls -al
total 0
drwxr-xr-x 1 vagrant vagrant 160 Dec 23 11:06 .
drwxr-xr-x 1 vagrant vagrant 320 Dec 23 11:06 ..
drwxr-xr-x 1 vagrant vagrant 96 Dec 23 11:06 e6
drwxr-xr-x 1 vagrant vagrant 64 Dec 23 11:06 info
drwxr-xr-x 1 vagrant vagrant 64 Dec 23 11:06 pack