git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git with detached worktrees , push has no effect
@ 2011-07-14 12:40 J. Bakshi
  2011-07-14 12:49 ` Carlos Martín Nieto
  0 siblings, 1 reply; 5+ messages in thread
From: J. Bakshi @ 2011-07-14 12:40 UTC (permalink / raw)
  To: git

Hello list,


I have set the git bare repo with detached worktree to update website with post-receive hook. In short what I have done

[1] create the bare git with hook
-------------------------------------

git init --bare /home/git/web.git

cat > home/git/web.git/hooks/post-receive
#!/bin/sh
GIT_WORK_TREE=/opt/web git checkout -f

chmod +x /home/git/web.git/hooks/post-receive

chown -rvf wwwrun:www /home/git/web.git


[2] create the directory and set permission
--------------------------------------------

mkdir /opt/web
chown -Rvf wwwrun:www /opt/web


[3] cloning at my clinet and push
-----------------------------------

 git clone http://192.168.1.1/git/web.git

Cloning into web...
Username:
Password:
warning: You appear to have cloned an empty repository.

 touch A
 git add A

 git commit -m "add A"

[master (root-commit) 7662edd] add A
 0 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 A

 git push
 Username:
 Password:
 Everything up-to-date


Why reports  [Everything up-to-date] rather than modify the remote git ?

Confused :-( 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: git with detached worktrees , push has no effect
  2011-07-14 12:40 git with detached worktrees , push has no effect J. Bakshi
@ 2011-07-14 12:49 ` Carlos Martín Nieto
  2011-07-15  5:25   ` J. Bakshi
  2011-07-15  5:26   ` J. Bakshi
  0 siblings, 2 replies; 5+ messages in thread
From: Carlos Martín Nieto @ 2011-07-14 12:49 UTC (permalink / raw)
  To: J. Bakshi; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 968 bytes --]

On Thu, 2011-07-14 at 18:10 +0530, J. Bakshi wrote:
[...] snip snip snip
> warning: You appear to have cloned an empty repository.
> 
>  touch A
>  git add A
> 
>  git commit -m "add A"
> 
> [master (root-commit) 7662edd] add A
>  0 files changed, 0 insertions(+), 0 deletions(-)
>  create mode 100644 A
> 
>  git push
>  Username:
>  Password:
>  Everything up-to-date
> 
> 
> Why reports  [Everything up-to-date] rather than modify the remote git ?

That's because your remote repository has no branches and per default
git-push will only push matching branches; as no branches match, there
is nothing to do. This is what "warning: You appear to have cloned an
empty repository." is trying to tell you (the message could certainly be
made much more friendly). Your master branch in this case doesn't exist
in the server, so you have to tell git to push it explicitly.

    git push origin master

will do the trick.

Cheers,
   cmn

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: git with detached worktrees , push has no effect
  2011-07-14 12:49 ` Carlos Martín Nieto
@ 2011-07-15  5:25   ` J. Bakshi
  2011-07-15  5:26   ` J. Bakshi
  1 sibling, 0 replies; 5+ messages in thread
From: J. Bakshi @ 2011-07-15  5:25 UTC (permalink / raw)
  To: Carlos Martín Nieto; +Cc: git

On Thu, 14 Jul 2011 14:49:27 +0200
Carlos Martín Nieto <cmn@elego.de> wrote:

> On Thu, 2011-07-14 at 18:10 +0530, J. Bakshi wrote:
> [...] snip snip snip
> > warning: You appear to have cloned an empty repository.
> > 
> >  touch A
> >  git add A
> > 
> >  git commit -m "add A"
> > 
> > [master (root-commit) 7662edd] add A
> >  0 files changed, 0 insertions(+), 0 deletions(-)
> >  create mode 100644 A
> > 
> >  git push
> >  Username:
> >  Password:
> >  Everything up-to-date
> > 
> > 
> > Why reports  [Everything up-to-date] rather than modify the remote git ?
> 
> That's because your remote repository has no branches and per default
> git-push will only push matching branches; as no branches match, there
> is nothing to do. This is what "warning: You appear to have cloned an
> empty repository." is trying to tell you (the message could certainly be
> made much more friendly). Your master branch in this case doesn't exist
> in the server, so you have to tell git to push it explicitly.
> 
>     git push origin master
> 
> will do the trick.
> 

GRAET !!

Working like a charm and the hook is also working fine. Can we make the 
empty master branch at the server, so that client can continue with plain "git push" ?

Thanks

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: git with detached worktrees , push has no effect
  2011-07-14 12:49 ` Carlos Martín Nieto
  2011-07-15  5:25   ` J. Bakshi
@ 2011-07-15  5:26   ` J. Bakshi
  2011-07-15 19:24     ` Carlos Martín Nieto
  1 sibling, 1 reply; 5+ messages in thread
From: J. Bakshi @ 2011-07-15  5:26 UTC (permalink / raw)
  To: Carlos Martín Nieto; +Cc: git

On Thu, 14 Jul 2011 14:49:27 +0200
Carlos Martín Nieto <cmn@elego.de> wrote:

> On Thu, 2011-07-14 at 18:10 +0530, J. Bakshi wrote:
> [...] snip snip snip
> > warning: You appear to have cloned an empty repository.
> > 
> >  touch A
> >  git add A
> > 
> >  git commit -m "add A"
> > 
> > [master (root-commit) 7662edd] add A
> >  0 files changed, 0 insertions(+), 0 deletions(-)
> >  create mode 100644 A
> > 
> >  git push
> >  Username:
> >  Password:
> >  Everything up-to-date
> > 
> > 
> > Why reports  [Everything up-to-date] rather than modify the remote git ?
> 
> That's because your remote repository has no branches and per default
> git-push will only push matching branches; as no branches match, there
> is nothing to do. This is what "warning: You appear to have cloned an
> empty repository." is trying to tell you (the message could certainly be
> made much more friendly). Your master branch in this case doesn't exist
> in the server, so you have to tell git to push it explicitly.
> 
>     git push origin master
> 
> will do the trick.
> 

Great !!

Working like a charm and the hook is also working fine. Can we make the 
empty master branch at the server, so that client can continue with plain "git push" ?

Thanks

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: git with detached worktrees , push has no effect
  2011-07-15  5:26   ` J. Bakshi
@ 2011-07-15 19:24     ` Carlos Martín Nieto
  0 siblings, 0 replies; 5+ messages in thread
From: Carlos Martín Nieto @ 2011-07-15 19:24 UTC (permalink / raw)
  To: J. Bakshi; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 990 bytes --]

On Fri, 2011-07-15 at 10:56 +0530, J. Bakshi wrote:
[snip]
> Working like a charm and the hook is also working fine. Can we make the 
> empty master branch at the server, so that client can continue with
> plain "git push" ?

You may have figured this out already, but once you push, that branch
exists, so under those same rules, pushing to master will work from
there onwards.

If you were asking whether you can create an empty branch on the remote
you it works "automatically", then the answer is no, because a branch
doesn't exist[0] before its first commit. A branch is a reference to a
commit (which is, logically, considered the tip of that branch). Thus an
empty branch cannot exist before any commits are made to that branch.

[0] For the purposes of network transfer. The way to create the first
commit ever in a repo (or in an orphan branch) is to have HEAD point to
an as-of-yet nonexistent branch; but this won't help you in this case.

Cheers,
   cmn


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-07-15 19:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-14 12:40 git with detached worktrees , push has no effect J. Bakshi
2011-07-14 12:49 ` Carlos Martín Nieto
2011-07-15  5:25   ` J. Bakshi
2011-07-15  5:26   ` J. Bakshi
2011-07-15 19:24     ` Carlos Martín Nieto

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).