threads / discuss / 1717

[PROBLEM] Checkout from cloned repository does not work

Subject: [PROBLEM] Checkout from cloned repository does not work

## tl;dr

5 messages between Sep 2, 2005 and Sep 3, 2005.

replies: 4people: 2as markdown or json

Pekka Enberg· Sep 2, 2005, 11:20 UTC · lore
Hi,

I cannot checkout from a cloned git repository I have created. I am using git 0.99.5 from Gentoo portage.

Following the tutorial, I create new git repository:
  $ mkdir git-test
  $ cd git-test/
  $ git-init-db
  defaulting to local storage area
  $ echo "Hello, Git" > hello
  $ git-update-cache --add hello
  $ git-write-tree
  4bd2134df7a908d2764f70d155e32650954cfc72
  $ echo "Initial commit" | git-commit-tree
4bd2134df7a908d2764f70d155e32650954cfc72 > .git/HEAD
  Committing initial tree 4bd2134df7a908d2764f70d155e32650954cfc72
Now on the server, I create a repository:
  $ mkdir git-test.git
  GIT_DIR=git-test.git/ git-init-db
Then I push my local repository to remote server like this:
  $ git push ssh.remote.server:/home/penberg/public_html/git-test.git master
  Password:
  updating 'refs/heads/master'
    from 0000000000000000000000000000000000000000
    to   8744316e49411509ba28e9cf567f3aec5833ec74
  Packing 3 objects
  Unpacking 3 objects
   100% (3/3) done
  refs/heads/master: 0000000000000000000000000000000000000000 ->
8744316e49411509ba28e9cf567f3aec5833ec74
After which I clone the newly created repository like this:
  $ git clone http://www.remote.server/~penberg/git-test.git cloned
  defaulting to local storage area
  Somebody should define smarter http server protocol
Now, the problem is that checkout does not work:
  $ git checkout
  usage: git-read-tree (<sha> | -m [-u] <sha1> [<sha2> [<sha3>]])
That's because I have no HEAD:
  $ ls -l .git/HEAD
  lrwxrwxrwx  1 penberg users 17 Sep  2 14:07 .git/HEAD -> refs/heads/master
  $ ls -l .git/refs/heads/
  total 0
What am I doing wrong here? Doing a git pull causes the following error:
  $ git pull http://www.remote.server/~penberg/git-test.git
  Fetching HEAD from http://www.remote.server/~penberg/git-test.git using http
  got 8744316e49411509ba28e9cf567f3aec5833ec74
  got 4bd2134df7a908d2764f70d155e32650954cfc72
  got b7aec520dec0a7516c18eb4c68b64ae1eb9b5a5e
  * committish: 8744316e49411509ba28e9cf567f3aec5833ec74  HEAD from
http://www.remote.server/~penberg/git-test.git
  cat: .git/HEAD: No such file or directory
  fatal: Needed a single revision
  git-resolve-script <head> <remote> <merge-message>
                                       Pekka
Junio C Hamano· Sep 2, 2005, 18:13 UTC · re: Pekka Enberg · lore

Re: [PROBLEM] Checkout from cloned repository does not work

Pekka Enberg <penberg@cs.helsinki.fi> writes:
> I cannot checkout from a cloned git repository I have created. I am
> using git 0.99.5 from Gentoo portage.
Show 6 quoted lines
> Following the tutorial, I create new git repository:
>...
> Now on the server, I create a repository:
>
>   $ mkdir git-test.git
>   GIT_DIR=git-test.git/ git-init-db

You would need 'chmod +x git-test.git/hooks/post-update' here if you are allowing people to pull over http from this repository.

I just realized that where this was documented was quite obscure in the tutorial. I'll update it with the appended patch.

Show 7 quoted lines
> After which I clone the newly created repository like this:
>
>   $ git clone http://www.remote.server/~penberg/git-test.git cloned
>   defaulting to local storage area
>   Somebody should define smarter http server protocol
>
> Now, the problem is that checkout does not work:

The problem is that 'git clone' does not support cloning over http from servers that are not properly prepared. This 'git clone' exited with non-zero status with an error message, didn't it?

-->8-- -->8-- -->8-- Mention post-update when we first talk about publishing a repository.

There is more detailed instruction for `project lead` later in the tutorial to talk about the same, but at this point in the flow of tutorial, the first time reader has no way of knowing it.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
diff --git a/Documentation/tutorial.txt b/Documentation/tutorial.txt
--- a/Documentation/tutorial.txt
+++ b/Documentation/tutorial.txt
@@ -1103,6 +1103,12 @@ your login shell is `bash`, only `.bashr
 `.bash_profile`. As a workaround, make sure `.bashrc` sets up
 `$PATH` so that you can run `git-receive-pack` program.
 
+[NOTE]
+If you plan to publish this repository to be accessed over http,
+you should do `chmod +x my-git.git/hooks/post-update` at this
+point.  This makes sure that every time you push into this
+repository, `git-update-server-info` is run.
+
 Your "public repository" is now ready to accept your changes.
 Come back to the machine you have your private repository. From
 there, run this command:
Pekka Enberg· Sep 3, 2005, 06:49 UTC · re: Junio C Hamano · lore

Re: [PROBLEM] Checkout from cloned repository does not work

Hi Junio,
On Fri, 2005-09-02 at 11:13 -0700, Junio C Hamano wrote:
> You would need 'chmod +x git-test.git/hooks/post-update' here if
> you are allowing people to pull over http from this repository.
Aah, thanks! That fixed it for me.
On Fri, 2005-09-02 at 11:13 -0700, Junio C Hamano wrote:
> The problem is that 'git clone' does not support cloning over
> http from servers that are not properly prepared.  This 'git
> clone' exited with non-zero status with an error message, didn't
> it?

I double checked that -- no, it does not print out an error. I copied the exact output in the original mail.

On Fri, 2005-09-02 at 11:13 -0700, Junio C Hamano wrote:
> +[NOTE]
> +If you plan to publish this repository to be accessed over http,
> +you should do `chmod +x my-git.git/hooks/post-update` at this
> +point.

How about "must do chmod before pushing anything to this repository"? I think I tried chmod at some point but always did it too late (i.e. after the initial push).

			Pekka
Junio C Hamano· Sep 3, 2005, 07:31 UTC · re: Pekka Enberg · lore

Re: [PROBLEM] Checkout from cloned repository does not work

Pekka Enberg <penberg@cs.helsinki.fi> writes:
> I double checked that -- no, it does not print out an error. I copied
> the exact output in the original mail. 

Which ended with the error message "Somebody should define smarter http server protocol". That's from git-clone-script and the echo to generate the output is followed by "exit 1".

Show 8 quoted lines
>> +[NOTE]
>> +If you plan to publish this repository to be accessed over http,
>> +you should do `chmod +x my-git.git/hooks/post-update` at this
>> +point.
>
> How about "must do chmod before pushing anything to this repository"? I
> think I tried chmod at some point but always did it too late (i.e. after
> the initial push).

I think "at this point" in the flow of tutorial text would be explicit enough, but I am not very good at writing documentation, so rewording/clarifying patches are always welcome.

You could always run git-update-server-info manually after pushing if you forgot to enable the hook. If you are paranoid you could run it with '-f' flag to rebuild the info from scratch.

Pekka Enberg· Sep 3, 2005, 07:43 UTC · re: Junio C Hamano · lore

Re: [PROBLEM] Checkout from cloned repository does not work

On Sat, 2005-09-03 at 00:31 -0700, Junio C Hamano wrote:
> Which ended with the error message "Somebody should define
> smarter http server protocol".  That's from git-clone-script and
> the echo to generate the output is followed by "exit 1".

Oh, I just didn't realize that was an error message. Perhaps it could have an "Error" prefix and an explanation that the repository was not cloned properly.

Anyway, thanks for the help!
			Pekka

← back to recent threads