LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Git unable to clone from "remote" to working dir on that server? (https://www.linuxquestions.org/questions/linux-software-2/git-unable-to-clone-from-remote-to-working-dir-on-that-server-4175421088/)

Jukas 08-08-2012 05:42 PM

Git unable to clone from "remote" to working dir on that server?
 
I've been using SVN at work, but we've never been able to fully take cleanly integrate branching & merging as I'd like so with that, and the desire to allow remote developers to have a fully distributed VCS I thought I'd take a look at git.

I setup git and gitolite on a CentOS 6.3 server that we'll call nix2 and added a single repository with some content.

On my local workstation (Macbook Pro OSX 10.8) I was able to git clone git@nix2.domain.com:admin.domain.com which I understand is the same as a svn checkout. I then added a files, committed and did a git push

Code:

MacBook-Pro:admin.domain.com jukas$ git push
Counting objects: 1191, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (1061/1061), done.
Writing objects: 100% (1190/1190), 1.58 MiB, done.
Total 1190 (delta 147), reused 0 (delta 0)
To git@nix2.domain.com:admin.domain.com
  a8fdd1f..6a1ec21  master -> master

All good so far, then I ssh'd to my server nix2 and tried to 'checkout' this content in my /www/htdocs/ directory only to have the remote server tell me it isn't a git repository...

Code:

[root@nix2 htdocs]# git clone git@nix2.domain.com:admin.domain.com
Initialized empty Git repository in /www/htdocs/admin.domain.com/.git/
git@nix2.domain.com's password:
fatal: 'admin.domain.com' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

So I went back to my Macbook, deleted the folder and re-did a git clone to test and it worked fine..

Code:

MacBook-Pro:sites jukas$ git clone git@nix2.domain.com:admin.domain.com
Cloning into 'admin.domain.com'...
remote: Counting objects: 1193, done.
remote: Compressing objects: 100% (915/915), done.
remote: Total 1193 (delta 147), reused 1190 (delta 147)
Receiving objects: 100% (1193/1193), 1.58 MiB | 1.32 MiB/s, done.
Resolving deltas: 100% (147/147), done.

No matter what I tried, I was unable to do a git clone on the remote server itself. This is trivial in svn, you juts create the dir and do a svn co svn+ssh://server/var/svn-repos/repo/trunk .

I've tried doing the git clone on the server itself as the following users root, git, jukas all with the same results. When I check /var/log/secure it just shows a ssh connection opening and closing.

I thought maybe this was a RTFM situation, but in reading the process seems pretty straightforward so I'm stumped what I'm doing wrong.

Any insight is much appreciated.

heinblöd 08-09-2012 05:04 AM

I'm not sure to understand the question completely :) but

maybe git uses a different syntax on OSX.

The syntaxt I'd use on Linux would be

Code:

git clone git@nix2.domain.com admin.domain.com
if "admin.domain.com" is the full name of your git repo

Jukas 08-09-2012 11:59 AM

Quote:

Originally Posted by heinblöd (Post 4749747)
I'm not sure to understand the question completely :) but

maybe git uses a different syntax on OSX.

The syntaxt I'd use on Linux would be

Code:

git clone git@nix2.domain.com admin.domain.com
if "admin.domain.com" is the full name of your git repo

I tried a git clone and was told it couldn't find the repo :(. I ended up fixing it, which I'll explain how later, but let me briefly explain my setup more clearly.

I have a CentOS server called nix2.domain.com. On that server in /www/htdocs/admin.domain.com I have existing content I wanted to manage via git (I'm used to SVN) but also access on my macbook as well as let a handfull of other developers have access to. Because the code is commercial and devs have to sign a NDA, I can't use a public github repo and would rather host my own git remote server than pay a monthly fee. Normally I would setup SVN on nix2.domain.com add the repos and then check out the code on the desired machines.

So on nix2 I added a user called git and created /home/git/repos/admin.domain.com and did a git init --bare. I then tried to clone /www/htdocs/admin.domain.com to git@nix2.domain.com:/home/git/repos/admin.domain.com and was told it didn't appear to be a git repo.

This is the same issue I experience prior when I tried to use gitolite to create and manage repos.


Here's how I was able to workaround and fix it, but surely I should be able to add existing content to a repo, and then clone it to the 'master repo' that the remote server is hosting?

As user git I created /home/git/repos/admin.domain.com and did a git init --bare. Then on my laptop I did a git clone git@nix2.domain.com:./repos/admin.domain.com and checked out an empty repo. Next I fired up my ftp client and downloaded the content from nix2 /www/htdocs/admin.domain.com into the workingdir I just cloned. Then I did a git add . followed by a git commit and a git push origin master. Then I went to /www/htdocs/ and tarballed admin.domain.com and deleted it before doing a git clone git@nix2.domain.com:./repos/admin.domain.com .

Once I found that workaround I was able to properly clone it both in the /www/htdocs dir and in a working dir on my macbook and push / pull between the two, however this is rather cumbersome as some of the sites I need to manage via VCS are rather large with many nested subdirs which makes ftp'ing content down to my laptop a pain in the butt.

Surely there's an easier way to accomplish this? As an aside question, if I plan on managing less than 20 repos is there a compelling reason to use something like gitolite or gitosis?

heinblöd 08-10-2012 04:31 AM

Well I'm not very deep into the git stuff. I have some local repos in our local net which are public as they are not reachable from the outside and I use cgit as a webinterface for that.
So maybe I can't help you much, but I remember I had once always empty repos when I tried to clone them.
Actually this was a stupid file and folder rigths thing.

The git-deamon is running as user git and when I used git init even as userX it creates an empty repo owned by user "git".

But when I added files, they were owned by "userx" and git add + git commit didn't touch them as user "git" had no rigths ...
So actually I have to do
Code:

su git
before adding files (or chown later if you prefer).

Maybe it helps ...


All times are GMT -5. The time now is 03:26 AM.