fatal: repository does not exist when cloning shared repository - linux

I'm trying to create a shared bare repository from an existing project so that multiple developers within the same group can have access. I have cloned the repository located in my project's directory to a bare shared repository in another centralized directory on the same machine and am able to create a clone of bare repo myself, however the clone fails with a fatal: repository does not exist error when logged in as another user within the group.
I've tried following the instructions on the git website for creating a bare repository and for cloning a repository.
https://git-scm.com/book/en/v2/Git-on-the-Server-Getting-Git-on-a-Server
https://git-scm.com/docs/git-clone
Based on the instructions, I used the following commands to create the bare repository and make it shared.
$ git clone --bare /path/to/my_dir/my_project /path/to/repos/project.git
$ cd /path/to/repos/project.git
$ git init --bare --shared
I am able to successfully make a clone using the following commands when I'm logged in as myself.
$ cd /path/to/their_dir
$ git clone /path/to/repos/project.git their_project
However, when logged in as a different user, the following error occurs when trying to use the same commands, even though I can do an ls on and cd into the project.git directory as the other user.
fatal: repository '/path/to/repos/project.git' does not exist
As far as permissions go, my account is listed as the owner of the repository and it's files, and the other user belongs to the group that is associated with the files.
$ ls -l /path/to/repos
drwxrws---. 6 me devs 4096 Jul 24 12:53 project.git
$ ls -l /path/to/repos/project.git
drwx------. 2 me devs 4096 Jul 24 12:46 branches
-rw-rw----. 1 me devs 177 Jul 24 12:53 config
-rw-------. 1 me devs 73 Jul 24 12:46 description
-rw-------. 1 me devs 23 Jul 24 12:46 HEAD
drwx------. 2 me devs 4096 Jul 24 12:52 hooks
drwx------. 2 me devs 4096 Jul 24 12:46 info
drwx------. 104 me devs 4096 Jul 24 12:46 objects
-rw-------. 1 me devs 98 Jul 24 12:46 packed-refs
drwxrws---. 4 me devs 4096 Jul 24 12:46 refs
How can I fix this so that another user can clone the repository while logged in under his or her account?

Related

npm ERR! Load key "/opt/app-root/src/.ssh/id_rsa": bad permissions in OCP S2I build

I have node applications where some dependency git repos specified in package.json and deploying using S2I in OCP. To clone the repos I have mounted the sshkey as a secret into /opt/app-root/src/.ssh .. But the permissions are coming default 6 to group that is root. And failing with error npm ERR! Load key "/opt/app-root/src/.ssh/id_rsa": bad permissions. Couple of suggestions from different git links are 1. Use hostpath 2. Runas root 3. Set fsGroup. How can I apply any of these changes into buildConfig? What ever I set in deployConfig is not reflecting for build.
ls -lasL /opt/app-root/src/.ssh
total 20
0 drwxr-xr-x. 3 default root 92 Jan 20 17:35 .
0 drwxrwxr-x. 1 default root 18 Jan 20 17:35 ..
0 drwxr-xr-x. 2 default root 39 Jan 20 17:35 ..2023_01_20_17_35_25.328954621
0 drwxr-xr-x. 2 default root 39 Jan 20 17:35 ..data
4 -rw-------. 1 default root 2610 Jan 20 17:35 id_rsa
16 -rw-------. 1 default root 12403 Jan 20 17:35 known_hosts

Jenkins build from git repository in Dropbox

I have a main Git bare repository in my Dropbox folder and I'm using a headless Debian server which runs Jenkins to build my projects.
Until now I've been using this approach to build my projects: I created a bare git repository on my headless server and configured the Jenkins job to pull the sources from this repository with the following URL: /var/cache/git/project. So when I want Jenkins to build my changes, I have to push them to this repository. This works fine, but it's not very convenient because I have to manually push to two repositories (Dropbox and Debian) and also when I want to add a new project, I need to create a new repository on the Debian server.
So I decided to configure the Jenkins jobs to pull directly from the Dropbox repositories. I've set up Dropbox on my Debian server at /home/jardo/Dropbox.
But when I try to configure the Jenkins job to pull drom URL /home/jardo/Dropbox/git/project.git, I get the following error:
Failed to connect to repository : Command "git ls-remote -h /home/jardo/Dropbox/git/project.git HEAD" returned status code 128:
stdout:
stderr: fatal: '/home/jardo/Dropbox/git/project.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
How come Jenkins is able to clone from /var/cache/git/project, but not from my Dropbox folder? Dropbox is completely synced and the repository content looks ok. I've set permissions on the whole repository recursively to 777 and that didn't help.
Here is the output of ls -l on my Dropbox repository:
-rwxrwxrwx 1 jardo jardo 104 Dec 15 21:10 config
-rwxrwxrwx 1 jardo jardo 73 Dec 15 21:10 description
-rwxrwxrwx 1 jardo jardo 23 Dec 15 21:10 HEAD
drwxrwxrwx 2 jardo jardo 4096 Dec 24 13:16 hooks
drwxrwxrwx 2 jardo jardo 4096 Dec 24 13:01 info
drwxrwxrwx 150 jardo jardo 4096 Dec 24 13:01 objects
drwxrwxrwx 4 jardo jardo 4096 Dec 24 12:59 refs
It turned out that user Jenkins could not access the GIT repository, which was owned by user Jardo, even when I tried to set its permissions recursively to 777. The solution was to setup Dropbox also for user Jenkins.

Git connection error : HTTP request failed

I've got a problem with git, which I used for years without problem, and which suddenly doesn't work anymore for any operation concerning remote repository (pull, push, clone).
Any of these operations returns :
error: couldn't connect to host while accessing https://me#bitbucket.org/me/myrepo.git/info/refs
fatal: HTTP request failed
I also tried with a repo hosted on github, it's the same.
BUT it works as sudo for example sudo git pull.
It really annoy me since it has always worked perfectly, and since I don't remember doing anything that could affect its behaviour (no system updates, no change of network configuration)
I already had a look to similar questions (this one and this another one) but it didn't help.
My config:
git version 1.7.9.5
Linux Mint 13 Maya
EDIT :
permissions of ~/.ssh and ~/.ssh/*
drwx------ 2 quentin quentin 4096 déc. 7 21:35 .ssh
-rw------- 1 quentin quentin 1766 déc. 7 21:34 id_rsa
-rw-r--r-- 1 quentin quentin 401 déc. 7 21:16 id_rsa.pub
-rw-r--r-- 1 quentin quentin 4968 déc. 7 21:32 known_hosts
EDIT 2:
Here's the result of strace git pull : http://pastebin.com/bAvBac22
Thanks to everyone that have an idea of what is wrong

GitLab: Could not read from remote repository

I created my project and added my ssh-key (both over webinterface), but when I try to push something to the repo, I get this error: "Could not read from the repository". This might be due to the fact, that the .git-project-file does not exist in the /home/git/repositories/[group]/ folder.
The gitlab-check returns:
[Group] / [Project] ... can't create, repository is empty
Error when pushing to repository
git remote add origin git#myserver.com:[group]/[project].git
git push -u origin master
fatal: '/home/git/repositories/[group]/[project].git' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
What might have caused the error
ls -ld /home/git/repositories/[group]/[project].git
File not found.
Why was the file not created?
Infos about my setup
ls -ld /home/ /home/git/
drwxr-xr-x 3 root root 4096 Aug 28 15:04 /home/
drwxr-xr-x 8 git git 4096 Aug 31 11:33 /home/git/
ll /home/git
drwxr-xr-x 8 git git 4096 Aug 31 11:33 ./
drwxr-xr-x 3 root root 4096 Aug 28 15:04 ../
-rw-r--r-- 1 git git 220 Aug 28 15:04 .bash_logout
-rw-r--r-- 1 git git 3637 Aug 28 15:04 .bashrc
drwx------ 2 git git 4096 Aug 29 19:52 .cache/
-rw-r--r-- 1 git git 88 Aug 31 11:33 .gitconfig
drwxr-xr-x 16 git git 4096 Aug 29 15:32 gitlab/
drwxr-xr-x 2 git git 4096 Aug 28 15:09 gitlab-satellites/
drwxr-xr-x 8 git git 4096 Aug 29 19:51 gitlab-shell/
-rw------- 1 git git 13 Aug 29 15:36 .mysql_history
-rw-r--r-- 1 git git 675 Aug 28 15:04 .profile
drwxrws--- 5 git git 4096 Aug 29 16:15 repositories/
drwx------ 2 git git 4096 Aug 31 11:47 .ssh/
-rw------- 1 git git 3453 Aug 29 16:03 .viminfo
sudo -u git -H bundle exec rake gitlab:env:info
RAILS_ENV=production
System information
System: Ubuntu 13.04
Current User: git
Using RVM: no
Ruby Version: 2.0.0p247
Gem Version: 2.0.3
Bundler Version:1.3.5
Rake Version: 10.1.0
GitLab information
Version: 6.0.0
Revision: 6c1c284
Directory: /home/git/gitlab
DB Adapter: mysql2
URL: http://myserver.com
HTTP Clone URL: http://myserver.com/some-project.git
SSH Clone URL: git#myserver.com:some-project.git
Using LDAP: no
Using Omniauth: no
GitLab Shell
Version: 1.7.0
Repositories: /home/git/repositories/
Hooks: /home/git/gitlab-shell/hooks/
Git: /usr/bin/git
sudo -u git -H bundle exec rake gitlab:check
RAILS_ENV=production
Checking Environment ...
Git configured for git user? ... yes
Has python2? ... yes
python2 is supported version? ... yes
Checking Environment ... Finished
Checking GitLab Shell ...
GitLab Shell version >= 1.7.0 ? ... OK (1.7.0)
Repo base directory exists? ... yes
Repo base directory is a symlink? ... no
Repo base owned by git:git? ... yes
Repo base access is drwxrws---? ... yes
post-receive hook up-to-date? ... yes
post-receive hooks in repos are links: ...
[Group] / [Project] ... repository is empty
Checking GitLab Shell ... Finished
Checking Sidekiq ...
Running? ... yes
Checking Sidekiq ... Finished
Checking GitLab ...
Database config exists? ... yes
Database is SQLite ... no
All migrations up? ... yes
GitLab config exists? ... yes
GitLab config outdated? ... no
Log directory writable? ... yes
Tmp directory writable? ... yes
Init script exists? ... yes
Init script up-to-date? ... yes
Projects have satellites? ...
[Group] / [Project] ... can't create, repository is empty
Redis version >= 2.0.0? ... yes
Your git bin path is "/usr/bin/git"
Git version >= 1.7.10 ? ... yes (1.8.1)
Checking GitLab ... Finished
ssh -T git#myserver.com
Welcome to GitLab, Christian Hammer!
cat /home/git/.ssh/authorized_keys
command="/home/git/gitlab-shell/bin/gitlab-shell key-2",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa [key] [email]
(Re)starting sidekiq solved the problem:
sudo -Hu git RAILS_ENV=production bundle exec rake sidekiq:start
From the information you have given, it is not able to create. Please check what exists inside of repositories/[group] directory.
If your repository is a bare repository (one which does not have working directory), then it is a convention to use a name like [project.git].
I had the same problem. But for me restarting sidekiq did not solve it. So i leave a small solution for the same error message. I manage the server gitlab is running on, so i created one key for remote ssh access (gitlab-server.pub) and another one (gitlab-repo.pub) for the repository. In the gitlab interface i uploaded gitlab-repo.pub but i forgot git to tell which one to use so after updating ~/.ssh/config like this everything works

svn permission issue - txn-current-lock: Permission denied

I setup svn on my local system /svn/repos/myproject by following this tutorial. I'm able to view the repo in browser.
But when it try to import new project I couldn't through svn client ( rapid svn ) it shows following error:
Execute: Import
Error while performing action:
Can't open file '/svn/repos/myproject/db/txn-current-lock': Permission denied
Svn directory permissions:
→ ls -l /svn
total 12
drwxrwxr-x 2 root root 4096 Feb 15 12:09 permissions
drwxrwxr-x 4 apache apache 4096 Feb 15 12:09 repos
drwxrwxr-x 2 root root 4096 Feb 15 12:09 users
Repo directory:
→ ls -l
total 8
drwxrwxr-x 3 root root 4096 Feb 15 12:09 conf
drwxrwxr-x 7 apache apache 4096 Feb 15 12:09 myproject
How to solve this issue?
I've given 777 permission to repos directory which solved this issue. But i got another issue like Couldn't perform atomic initialization.
I think this is due to incompatible sqlite version with subversion we're using, this can be solved by updating svnadmin command,
svnadmin create --pre-1.6-compatible --fs-type fsfs /svn/repos/myproject

Resources