GIT clone and first GIT push issue

I have two questions. I have Ubuntu 10.10 and I installed a git server with a guitar tool. Everything worked well. The glit setup team of githolite created 2 repositories: gitolite-admin and testing.

1) QUESTION 1

My admin user, gitolite, is by default called "git" and has already been created.

Firstly, I had to clone the gitolite-admin repo, make some changes to say conf / gitolite.conf, to add a new repo and a new user (I added the root user and I created as well as the private / public key before and also added public key in the keydir folder), then I had to add / commit and push the changes back.

Info: I have a ~ git / file. ssh / authorized_keys starting with command = and having only one value is the public key of the git user that I created first.

DOES NOT WORK:

git@vs1 :~/$ git clone git@ <<SERVER_IP>>:gitolite-admin.git Initialized empty Git repository in /home/git/ga/gitolite-admin/.git/ git@ <<SERVER_IP>> password: fatal: 'gitolite-admin.git' does not appear to be a git repository fatal: The remote end hung up unexpectedly 

HAVE WORKED:

 touch ~/.ssh/config 

with content:

 host gitolite user git hostname <<SERVER_IP>> identityfile ~/.ssh/git.pub git@vs1 :~/$ git clone gitolite:gitolite-admin Initialized empty Git repository in /home/git/ga/gitolite-admin/.git/ Enter passphrase for key '/home/git/.ssh/git.pub': Enter passphrase for key '/home/git/.ssh/git.pub': Enter passphrase for key '/home/git/.ssh/git.pub': git@89.35.160.243 password: remote: Counting objects: 23, done. remote: Compressing objects: 100% (18/18), done. remote: Total 23 (delta 4), reused 0 (delta 0) Receiving objects: 100% (23/23), done. Resolving deltas: 100% (4/4), done. 

Why didn’t I work in the first version at all? All textbooks say that it should work without problems. I had to use the second option with creating this host configuration in the ~ / .ssh / config file. This is a little disappointing. The repo path is / home / git / repositories, and ssh is the default port 22.

2) QUESTION 2

Using the root of the user on the same server, I created an empty folder, let it say /var/www/example.com/www. I ran git init, then added the file (.gitignore), ran git add -A and git commit -m "...".

Then I created a remote path for the source:

 git remote add origin git@ <<SERVER_IP>>:myrepo.git 

I ran git push origin master, and this is what I got:

 fatal: 'myrepo.git' does not appear to be a git repository fatal: The remote end hung up unexpectedly 

I tried different things to change, for example, put it all the way to the repository (even I did not see it anywhere, so this is wrong), and I got:

 Counting objects: 3, done. Writing objects: 100% (3/3), 243 bytes, done. Total 3 (delta 0), reused 0 (delta 0) remote: ENV GL_RC not set remote: BEGIN failed--compilation aborted at hooks/update line 20. remote: error: hook declined to update refs/heads/master To git@ <<SERVER_IP>>:/home/git/repositories/myrepo.git ! [remote rejected] master -> master (hook declined) error: failed to push some refs to ' git@ <<SERVER_IP>>:/home/git/repositories/myrepo.git' 

What am I doing wrong? This is frustrating, because for such a basic task I experience such unusual difficulties. I have a lot of experience with SVN, these are the first games with GIT.

Thank you in advance for your help!

+4
source share
1 answer

Note for 1 /: This might work if the identityfile was the default name ( id_rsa.pub and id_rsa ). Since this is not the case, the config file was required.

Note for 2 / did you create a git repository, but did you let gitol know about it?
You must declare a new repo in the gitolite-admin repository configuration file .

If you push ssh as root , that means the usage has its own keys ~/.ssh/id_rsa(.pub) , and these keys were registered for Gitolite.

Note for repo paths: never use the full local repo path for the push / pull address: this completely circumvents the Gitolit.


Gazillon comments on laters, it seems that:

  • all remote addresses should start with git@somehostname : arepo.git : you want your user to execute git commands on somehostname as " git " (an account in charge of git and gitolit).
    This means that the public key " myuser " must be registered with somehostname:~git/.ssh/authorized_keys

  • anytime an ssh connection is not good for you, you can start by looking for tips on debugging ssh .
    For example: ssh -vvv git:somehostname can go a long way to illustrate what happens

  • if you want to avoid the config file then you need to use the standard naming convention for these public / private keys ( ~myuser/.ssh/id_rsa and ~myuser/.ssh/id_rsa.pub )

+1
source

Source: https://habr.com/ru/post/1393448/


All Articles