Cannot rebase, stash or commit git repo on host filesystem from Vagrant machine: Unable to create /.git/index.lock

eComEvo

Tried rebasing to production branch off a clean branch I haven't made any changes to that is a little behind.

Was told I have uncommitted changes and to either commit them or stash them, but git status reveals no changes were made to any files on this branch.

So just for the hell of it, decided to stash changes. When I try that, I get error:

fatal: Unable to create '/var/www/MyProject/.git/index.lock': Permission denied
Cannot save the current index state

So I tried this trick:

sudo rm -f /var/www/MyProject/.git/index.lock

But that didn't help. So I tried again, following that command with git reset but reset throws the same permission denied error.

So then I tried sudo git reset which worked, but then when I tested git rebase production I get this error:

First, rewinding head to replay your work on top of it...
fatal: Unable to create '/var/www/MyProject/.git/index.lock': Permission denied
could not detach HEAD

How do I fix these permission issues?

This is a vagrant box running Ubuntu 14.04.

Paul Hicks

You are using different users to create and manage your repository. Your repo was created by www-data and you're logged in as vagrant.

Your options are:

  1. Log in as www-data (su www-data) before doing git work.
  2. Change the owner of the repo to vagrant (chown -R vagrant *)
  3. Change the permissions on the repo to allow group write since both ids are in the vagrant group (chgrp -R vagrant *)
  4. Mount the disc or directory using the correct owners and permissions. For Vagrant, your Vagrantfile's config.vm.synced_folder configuration covers this: see the Vagrant Docs.

Whatever you do, make sure anything else that needs to use git retains whatever access it needs. Since www-data created the repo, it's likely that you used some sort of web service / application to do it; therefore, if you change the owner of the repo to vagrant, you probably need to change the web service / application so that it is run by vagrant, too.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Git: "Cannot 'squash' without a previous commit" error while rebase

From Dev

How to connect with host PostgreSQL from vagrant virtualbox machine

From Dev

Using Vagrant, access app on host machine from inside Vagrant

From Dev

clone from a git repo and commit to a new repository

From Dev

Rebase git repo from different repo

From Dev

Unable to commit to an empty git repo

From Dev

git line endings - can't stash, reset and now can't rebase over spurious line endings commit

From Dev

Unable to access Sinatra app on host machine with Vagrant forwarded ports

From Dev

git-svn fails to commit back to svn repo despite clean rebase

From Dev

Unable to connect to Vagrant private network from host

From Dev

Cannot clone private repo from Vagrant provision file

From Dev

Unable to scp files from local machine into vagrant

From Dev

Fetch specific commit from remote git repo

From Dev

Vagrant + Docker + Postgresql - Cannot connect from host

From Dev

Vagrant ping or curl from guest to host machine

From Dev

Access web server on VirtualBox/Vagrant machine from host browser?

From Dev

Git Error: stash or commit

From Dev

Stash the very first commit on an empty project repo

From Dev

How can I create a GIT Stash from a Commit?

From Dev

How can I resume rebase after "Unable to create '.git/index.lock': File exists."?

From Dev

push from git/svn repo into a git/branch at specific commit

From Dev

Unable to ping from VM's to host machine

From Dev

Cannot rebase, stash or commit git repo on host filesystem from Vagrant machine: Unable to create /.git/index.lock

From Dev

Stash the very first commit on an empty project repo

From Dev

How can I create a GIT Stash from a Commit?

From Dev

Unable to connect to MySQL VM from host machine

From Dev

Cannot push to remote git repo from one machine to another in LAN

From Dev

Jenkins Artifactory Release Plugin Unable To Commit Tag (Windows Host Machine)

From Dev

Teammate unable to push commit to shared Bitbucket repo using Git

Related Related

  1. 1

    Git: "Cannot 'squash' without a previous commit" error while rebase

  2. 2

    How to connect with host PostgreSQL from vagrant virtualbox machine

  3. 3

    Using Vagrant, access app on host machine from inside Vagrant

  4. 4

    clone from a git repo and commit to a new repository

  5. 5

    Rebase git repo from different repo

  6. 6

    Unable to commit to an empty git repo

  7. 7

    git line endings - can't stash, reset and now can't rebase over spurious line endings commit

  8. 8

    Unable to access Sinatra app on host machine with Vagrant forwarded ports

  9. 9

    git-svn fails to commit back to svn repo despite clean rebase

  10. 10

    Unable to connect to Vagrant private network from host

  11. 11

    Cannot clone private repo from Vagrant provision file

  12. 12

    Unable to scp files from local machine into vagrant

  13. 13

    Fetch specific commit from remote git repo

  14. 14

    Vagrant + Docker + Postgresql - Cannot connect from host

  15. 15

    Vagrant ping or curl from guest to host machine

  16. 16

    Access web server on VirtualBox/Vagrant machine from host browser?

  17. 17

    Git Error: stash or commit

  18. 18

    Stash the very first commit on an empty project repo

  19. 19

    How can I create a GIT Stash from a Commit?

  20. 20

    How can I resume rebase after "Unable to create '.git/index.lock': File exists."?

  21. 21

    push from git/svn repo into a git/branch at specific commit

  22. 22

    Unable to ping from VM's to host machine

  23. 23

    Cannot rebase, stash or commit git repo on host filesystem from Vagrant machine: Unable to create /.git/index.lock

  24. 24

    Stash the very first commit on an empty project repo

  25. 25

    How can I create a GIT Stash from a Commit?

  26. 26

    Unable to connect to MySQL VM from host machine

  27. 27

    Cannot push to remote git repo from one machine to another in LAN

  28. 28

    Jenkins Artifactory Release Plugin Unable To Commit Tag (Windows Host Machine)

  29. 29

    Teammate unable to push commit to shared Bitbucket repo using Git

HotTag

Archive