On Linux Debian 9, I'm trying to create a git (ver. 1:2.11.0-3+deb9u2) repository within a Cryptomator (ver. 1.3.2) WebDAV server mounted via davfs2 (ver. 1.5.4-2+b1). After running git init to create the git repo, I get the following error:
error: could not lock config file /home/nonrootuser/Documents/mounteddrive/gitrepo/.git/config: Permission denied
fatal: could not set 'core.repositoryformatversion' to '0'
Same issue persists with nonrootuser and root.
To reproduce:
git and davfs2 are available via Debian repositories. Cryptomator 1.3.2 is available here:
https://github.com/cryptomator/cryptomator/releases/tag/1.3.2
Create a blank folder for the davfs2 mount:
cd /home/nonrootuser/Documents/
mkdir mounteddrive
Create a vault with Cryptomator and unlock it. For the unlocked vault, click the dropdown arrow and select Copy WebDAV URL. Paste the WebDAV URL into the following command and run in terminal:
mount -t davfs -o gid=nonrootuser,uid=nonrootuser pasteWebDAVURLhere /home/nonrootuser/Documents/mounteddrive
(hit enter twice, leaving Username and Password blank)
The Cryptomator vault is now mounted to the folder mounteddrive.
In terminal, run the following:
cd /home/nonrootuser/Documents/mounteddrive
mkdir gitrepo
cd gitrepo
git init
Here you should see the error described above. However, a .git folder is still created within the gitrepo directory. When running ls -la in gitrepo, it seems to indicate I have the appropriate permissions, and I can create arbitrary files within the .git folder; what I cannot create is an empty file called config.lock, which I believe is what git is trying to do.
This may be completely off-base, but I've tried turning locks on and off (see use_locks) in the davfs2.conf file that can be edited by running the following as root:
mousepad /etc/davfs2/davfs2.conf
To try to obtain the appropriate permissions to create config.lock, I've tried changing my git user.name to "root" and "nonrootuser":
git config --system user.name "root"
git config --global user.name "root"
and
git config --system user.name "nonrootuser"
git config --global user.name "nonrootuser"
I've also tried running the following in the gitrepo folder as both root and nonrootuser:
chmod -R 777 .git
However, git init still returns an error.
git is working fine on my system outside of cryptomator/davfs2 mounts. I've not used davfs2 previously without cryptomator, so I don't know if the former, latter, or both are the problem.
Any ideas are appreciated.
Related
Want
I wanna manage nvim config by git.
Problem
Link is break by git checkout . command. Expect behavior is overwrite my nvim config with remote repository source. But actual behavior is overwrite link with remote repository source.
Code
I was tried as bellow code.
# clone
cd ~/Documents/GitHub/
git clone https://github.com/ShortArrow/my-nvim-config
cd my-nvim-config
# delete "./nvim" for making link
rm -r ./nvim
# making link
ln -s ~/.config/nvim/ ./nvim
# if you need, "cp ~/.config/nvim/ ~/.config/nvim-backup"
# I wanna rewrite nvim config by git with this command
git checkout .
Already Tried
try1
sudo git config --system --unset core.symlinks
git config --local core.symlinks false
try2
$> sudo ln -d ~/.config/nvim/ ./nvim
ln: failed to create hard link './nvim' => '/home/who/.config/nvim/': Operation not permitted
On Windows
This github repository is working good with Junction link on Windows.
A softlink is just a file with the target path in it (and a permission flag telling the OS to treat it as a link), and Git is treating it as such.
Instead of changing what is in the repository by changing the repository file into a link to the config file, link the other way: make the config file link into the repository.
I am trying to clone a private GitHub repository in a server that I am trying to get up and running on a virtual machine.
No matter what I do, I keep getting the following error:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I have tried a bunch of things. For starters, I made sure that I made my rsa keys correctly by following GitHub's tutorial. I am also sure that my public rsa key found at ~/.ssh/id_rsa.pub was correctly copied over to my GitHub account's ssh keys.
My config file at ~/.ssh/config looks like the following:
Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_rsa
I have tried cloning a public repository and a private repository, and both don't work.
When I go to clone the repository I am executing the following command:
sudo git clone git#github.mit.edu:<GitHub Name>/<Repo Name>.git
If I execute the command without sudo, I get the following error:
fatal: could not create work tree dir '<Repo Name>'.: Permission denied
I am inside of a Python virtual environment when I do all of this. Does that make any difference?
I have been reading Stack Overflow posts related to this matter, but none of them are helping me address my issue.
Any help would be greatly appreciated! Thank you!
You are using sudo so Git is using ssh keys of user root.
To make this work you'd have to call git without sudo.
So when I don't use sudo I get the error fatal: could not create work
tree dir 'cardlearning'.: Permission denied
Make sure current user has write permission in directory you are executing the clone.
You can't clone into existing directory so as a workaround you can:
$ sudo mkdir tmp
$ sudo chown $USER: tmp
$ git clone git#github.mit.edu:<GitHub Name>/<Repo Name>.git tmp/cardlearning
$ mv tmp/cardlearning ./cardlearning
$ rmdir tmp
Check that your user has permissions to write to the directory you are in.
or execute
git clone git#github.mit.edu:<GitHub Name>/<Repo Name>.git ~/myRepo
to place it in the myRepo subdirectory of your home directory.
Do not use sudo to edit your ssh config when using a ~ referenced path, as you may end up editing the root user's ssh preferences and not your users. Likewise do not clone repositories using sudo as it will attempt to connect using the root user's ssh key.
It fails with warning: unable to unlink ... Permission denied
Order of operations:
Deleted some files, added the deleted files to staged files.
# On 1st local remote repository:*
git commit -m "deletion of folder with files"
# pushed to remote repository
git push origin branchName
# On local repository
git pull
gives the error: warning: unable to unlink ... Permission denied
I see that the files were not deleted.
Maybe it's related to the fact that repository is in /var/wwww/html ?
Usually i make changes with sudo there.
It seems also that change was applied in index after running:
git log -1
How to correctly apply this deletion by git pull ?
Running git pull now returns
Already up-to-date.
Your issue here is operating system permissions. It has nothing to do with git. If you look at your git status for that repo, you will likely see the files in /var/www/html as new untracked files as git thinks you've already deleted them. I would recommend finding a user that has the appropriate permissions and deleting them manually, or running something like the following:
sudo git reset --hard && git clean -fdx .
WARNING: This command will delete any non-tracked files and reset any tracked changes.
I have an problem with my client/server git configuration which is creating permissions issues when there are multiple users pushing changes. My users are getting the error:
remote: error: insufficient permission for adding an object to repository database ./objects
My Configuration
The git repository is located on a NetApp network share. This network share is mounted on a Red Hat (RHEL) 6.4 Linux Server. To create the repository the user logs into the RHEL Server, navigates to where they want the repository (on the mounted share) then run the command:
git init --bare --shared=true repo.git
Each user is works locally on their own Windows 7/10 machine, they have git windows installed, and they have the previously mentioned network share mapped as a drive. To get the repository on their machine they open git-bash and navigate to where they want to clone the repo locally. They then run:
git clone Z:/git_repo_location/repo.git
The Issue
Users are able to push changes to the repository and everythings works fine until they attempt to push changes to a file which someone else had previously edited. This is when the error listed above rears its ugly head.
Reviewing the permissions from RHEL it appears that the folders in repo.git/objects are set to 755.
I believe what is happening is when an objects folder is owned by User A, User B is unable to push changes to the affected files. As a note I have had all users update their umask in git-bash to 0002 (from the default 0022). Also all files/folders in the repo.git repository are owned by group "DTG" and all users working on this repo belong to this group.
Attempted Fixes
I have tried creating/initializing repositories several other ways but each one has the same results:
Create repo2.git
git init --bare repo2.git
cd repo2.git
git config core.sharedRepository group
chgrp -R dtg .
chmod -R g+w .
chmod g+s `find . -type d`
Create repo3.git
git init --bare repo3.git
cd repo3.git
chgrp -R dtg .
chmod -R g+w .
chmod g+s `find . -type d`
git init --bare --shared=all
Create repo4.git
git init --bare repo4.git
cd repo4.git
git config core.sharedRepository true
chgrp -R dtg .
chmod -R g+swX .
chmod g+s `find . -type d`
git init --bare --shared=all
I have also tried having the users clone the repository while setting the local sharedRepository config
git clone --config core.sharedRepository=true Z:/git_repo_location/repo.git
So far the only thing that fixes this issue is if I log into the RHEL machine and add the group permission to the objects folders:
chmod -R g+w repo.git/objects/
The problem is that this is only a temporary bandaid to fix the immediate issue. But as soon as someone pushes changes again I'm left with objects folders missing the group write permisison and the next user will be blocked again.
Any help figuring this out would be greatly appreciated!!! Also if any additional information is needed please let me know. Most of the attempted solutions above come from another similar question How to configure an existing git repo to be shared by a UNIX group
this seems to be a problem of the middle-layer for file-sharing.
assuming you are actually using SAMBA to provide a network share to be mounted from the w32 guests, the umask and similar settings will not help you very much (since permissions are actually handled by the samba server and the w32 client - the latter often trying to make very restrictive files)
you might have luck with something like:
[git]
comment = GIT repositories
path = /path/to/git/repos
read only = No
force group = dtg
create mask = 0664
directory mask = 0775
force directory mode = 0770
force create mode = 0660
here is the situation: i want to use git to track a directory of preference files that are owned by root.
it would be nice if git commands that don't modify the files (like git status and git diff) can be run as the user (without sudo).
through the following steps, i've created a repo that seems to function in a reasonable manner:
sudo mkdir .git
sudo chmod <user>:<group> .git
git init
git add .
git commit -m "initial commit"
i can run git status and git diff as the user. git checkout ... and git reset ... fail as the user, but seem to run fine when prefixed with sudo.
this seems perfect: no sudo needed to get into the repo and take a look at what's gone on, but to change the tracked files requires an extra level of effort, as it should for system files.
the question is: will this cause me any problems with how git is reading and writing files inside the .git directory? will any commands i need sudo to run end up creating things inside .git with root permission that will then cause problems trying to run commands that don't modify the tracked files as the user?
thanks and advance for any answers.