gitlab clone fails with could not read from remote repository - gitlab

While trying to clone a repository from gitlab, I ran into the following error:
git clone <USER>#<URL>:<path_to_project.git>
Cloning into 'xxx'...
<USER>#<URL>'s password:
fatal: 'root/acl-labl-website.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.
I tried both the SSL and HTTP address, and both got this similar error. Not sure what it meant, and after many tries involving modifying config files (from gitlab, nginx, apache checking redirects, etc.), I found the very simple answer. Still not sure why my other method didn't work, but I found that first adding your public ssh key to gitlab (through the GUI), then using the same command as above, but using git instead of my username:
git clone git#<URL>:<repo_path>.git
worked. I.e. generate your id_rsa.pub as explained here: https://docs.gitlab.com/ce/ssh/README.html , copy this to your ssh keys (which in my case was one of the tabs in the gitlab GUI; I've done this before for git as well, where it's also to be found somewhere in your user settings). In my case I had to run
ssh-add
still before it worked, but with a colleague it worked without as well.
Then the cloning using git# instead of username# worked perfectly. Again; still not sure why it won't work using my username and password (same as the one I use to login to the gitlab GUI), so if someone could shed some light on that, I'd be interested in it. But since it took my quite some time before I found this solution/work-around, thought I'd post it here. Perhaps better suited to serverfault actually, but since I suspect many people end up here as well, perhaps the admins can live with this post here :)

Related

Issue with authentication using Git Kraken and self hosted Gitlab

so I have a self-hosted Gitlab, I use Git kraken pro and git for windows to enable the LFS component.
I'm having the issue where when I push to my repository git kraken asks for authentication. (Username and password.) How ever I have no such issue when I pull the data, it will just do the job. And the same is for the LFS, I can pull but not push the data without a password.
Here is the set up:
I have not been successful in setting up the ssh keys at this point as it refuses to use them and I'm still trying to work that issue out.
I have pressed the "remember me" option for the pop up and that doesn't seem to work
I have set up the access token and that all works.
The GitLab ce is installed on a Linux OS and I am connecting to it via 4 windows PC's using git kraken (all on pro licenses).
Git lab CE is updated to the latest version and same for git Kraken
Obviously, the preferred method of connection to the git is SSH but it refuses to work. I have tried the git kraken's version of ssh and manually creating and installing the keys using cmd line.
When I enter the U/P to push the data it only works for that single push even if I don't restart git lab. Every single time I need to place a user name and password and this is tiresome.
What I'm asking is, how can I fix this? This is my first full-fledged self-hosted git, and I've learned things on the fly, I do have normal git experience but the set up for the self-hosted is a lot more involved compared to just using git itself.
The reason I am self-hosting is, cost. My repos are GB in size and I have many. So, I need to have my own set up to avoid having those kinds of costs.
How can this be fixed?
When I enter the U/P to push the data it only works for that single push even if I don't restart git lab. Every single time I need to place a user name and password and this is tiresome.
Double-check if your GitKraken is actually using an SSH URL (git#yourServer:user/repo), as a username/password should only work for HTTMS URL (https://yourServer/user/repo)
Check the SSH port is reachable from your windows:
curl -v telnet://yourServer:22
If it does not connect, double-check your Omnibus installation on Linux, making sure the SSH daemon is started and active, using the right sshd_config.
The OP Maize adds in the comments:
A complete reinstall and removal of setting in GitKraken solved the issue.
Previous uninstalled seems to of kept the settings, so when I removed those, it sorted itself out.

Use git server without git user

I have a remote linux machine with only one user.
I just set up git repos on it without a git user. But all the tutorials suggest me to use the git user. So right now I am using
git clone user#hostname:/path/to/git/directory/your_project.git
rather than :
git clone git#hostname:/path/to/git/directory/your_project.git
And it works fine.
If I use the git account, for each project I have to change permission for that project and change the config to share the directory.
Does using the setting up and using a git user have any advantage over using your user account on linux?
Not much, maybe convention - git automation tools and APIs might expect a git user, but I've never come across such a situation.
Sources: https://git-scm.com/book/en/v1/Git-on-the-Server-The-Protocols and https://www.digitalocean.com/community/tutorials/how-to-set-up-a-private-git-server-on-a-vps
The second one describes the creation of a git user, and then you get the URLs (over SSH, using a SCP-like syntax, as referenced in the first article's second method) to be git#server:.
You've essentially done the same thing but with whatever user instead of a user named git, so you get user#server:

How to sync git on ubuntu with existing github projects?

I used mac github client to push my codes to my github account. On my Ubuntu linux computer I wan't to connect to github using the terminal so that it will automatically sync will all my projects on github. How would I do it? All the online help I have bumped in to so far only show how to clone an exiting git repository not how to connect to my github account and sync it.
git, the revision control system, doesn't know anything about Github, a website that keeps track of and hosts your git repositories for you. The concept of a Github account is totally alien to git, so you'll never be able to, say, browse all of the projects you own on Github with a git command. git only works on the level of individual repositories.
Github also provides a graphical client that handles both the git level stuff and the Github level stuff -- it understands what a Github account is, and will log in for you and display all of the repos associated with the account. It's also a fully featured git client that does a lot of work on the level of individual repos for you. However, this graphical client is currently only available for Windows and OS X, and is not available for Linux.
My own workflow on Linux is to use the github.com website plus the command-line git tool. To bridge the gap between Github and git, you need to git clone individual repos. Aside from that, you can do Github administrative tasks on the website, and you can work with individual repos with git on the command line.
If you don't like this work flow, you need to look at graphical git clients for Linux. I'm not sure if any exist that will do both git-level stuff and also interface with Github specifically and understand the idea of a Github account.
You could also theoretically try to run the Windows client in wine on Linux, but I would not recommend this approach except as a last resort.
First I don't know a program that automatically sync all my github repositories.
First you have to install git (if it has not been done already) tutorial
Than you should generate a rsa:key to be able to 'push' your repositories to github.
You can generate a rsa_key by following this tutorial notes ssh-add id_rsa should be ssh-add id_rsa.pub ....also you can name id_rsa as anything you want: like bran_rsa_key
You should post or add your rsa_key to git hub at this address. If you go to that link you will see that you already have some key for your Mac but nothing for your Ubuntu.
After installation you could install ungit if you're not that familliar with git

JGit : connect to distant repository

I searched through Google, forums and JGit user guide but couldn't find how to connect to a distant repository with the API.
Anyone has an example or just an idea on how to do that?
Thanks for your help.
Currently, JGit 2.0.0-SNAPSHOT does only offer
org.eclipse.jgit.storage.file.FileRepository
org.eclipse.jgit.storage.dfs.InMemoryRepository
concrete Repository classes, meaning that since org.eclipse.jgit.api.Git takes a Repository, it is not possible to work remotely. Since Git by itself is not designed to operate remotely in the way I think you mean, I doubt we will see such a feature any time soon.
MORE ON THAT:
Consequently, you will need to clone locally. You do that by issuing
Git.cloneRepository()
.setURI(myRemoteURIString)
.setDirectory(new File(myLocalPathString))
.call();
However, for reasons of consistency in Git you should clone a bare repository only, so a non-bare repository in a remote location, while not technically, is practically inaccessible.
I am not sure I understand the question since Git is made for accessing other repositories, this is what is meant by "Git is distributed".
If you want to connect to ONE distant repository, then yeah you should clone it.
I don't know if that is what you are looking for, but you can also use multiple remotes. Adding one more is done with Git using git remote add <remote_name> <remote_uri>. As for Jgit, I unfortunately can't remember the code to do it simply, but you can figure this out.
At least it's possible by modifying the configuration, calling getConfig() from a Repository object and then calling setString(...) on it - don't forget to save the configuration in the end. But before modifying the configuration, I think you should first get to know more about Git and JGit.
I recommend you to read more about it, and play a bit with your repository. Take a look at this article : http://caiustheory.com/adding-a-remote-to-existing-git-repo .
Another one that will help you down the road is How do I do the equivalent of “git remote update” with jgit?
Maybe someone else knows exactly which commands to run and can help.

Setting Commit and Checkout Privileges for a Git Repository

We are having a local repository which is accessible to a large number of people. We have to set up a Git repository there such that only certain users have checkout as well as commit privileges. How can we do that.
P.S. : This is a part of our homework assignment in which we have to develop a game and update it using a Git repository. So, if anyone feels like we should not be asking this question here, please do tell.
I'd recommend gitolite to manage user access to the repository.
Edit after comments:
gitolite is installed via git too.
I'm guessing that your teacher probably also meant to teach you – besides using git – to configure git protocols, ssh access (keys etc.).
You already got best advices: gitolite, gitosis, Pro git, adding to this man ssh, man ssh-keygen, man scp and git manual your homework should be easily solved.
Since it is homework I will try to give hints.
What files and directories do other users need to read to access (or write to commit/push into) a repository?
What methods can you use to control the permission on these files and directories?
Does your application have any configuration options that might help?

Resources