{"thread":{"id":"27814","subject":"git with detached worktrees , push has no effect","startedAt":"2011-07-14T12:40:19Z","lastAt":"2011-07-15T19:24:59Z","messageCount":5,"participants":["J. Bakshi","Carlos Martín Nieto"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"171332","messageId":"20110714181019.2453e3a8@shiva.selfip.org","threadId":"27814","inReplyTo":null,"subject":"git with detached worktrees , push has no effect","fromName":"J. Bakshi","fromEmail":"joydeep@infoservices.in","sentAt":"2011-07-14T12:40:19Z","receivedAt":"2011-07-14T12:40:19Z","isPatch":false,"sender":{"key":"joydeep@infoservices.in","avatar":null},"body":"Hello list,\n\n\nI have set the git bare repo with detached worktree to update website with post-receive hook. In short what I have done\n\n[1] create the bare git with hook\n-------------------------------------\n\ngit init --bare /home/git/web.git\n\ncat > home/git/web.git/hooks/post-receive\n#!/bin/sh\nGIT_WORK_TREE=/opt/web git checkout -f\n\nchmod +x /home/git/web.git/hooks/post-receive\n\nchown -rvf wwwrun:www /home/git/web.git\n\n\n[2] create the directory and set permission\n--------------------------------------------\n\nmkdir /opt/web\nchown -Rvf wwwrun:www /opt/web\n\n\n[3] cloning at my clinet and push\n-----------------------------------\n\n git clone http://192.168.1.1/git/web.git\n\nCloning into web...\nUsername:\nPassword:\nwarning: You appear to have cloned an empty repository.\n\n touch A\n git add A\n\n git commit -m \"add A\"\n\n[master (root-commit) 7662edd] add A\n 0 files changed, 0 insertions(+), 0 deletions(-)\n create mode 100644 A\n\n git push\n Username:\n Password:\n Everything up-to-date\n\n\nWhy reports  [Everything up-to-date] rather than modify the remote git ?\n\nConfused :-( \n"},{"id":"171334","messageId":"1310647767.6041.73.camel@centaur.lab.cmartin.tk","threadId":"27814","inReplyTo":"20110714181019.2453e3a8@shiva.selfip.org","subject":"Re: git with detached worktrees , push has no effect","fromName":"Carlos Martín Nieto","fromEmail":"cmn@elego.de","sentAt":"2011-07-14T12:49:27Z","receivedAt":"2011-07-14T12:49:27Z","isPatch":false,"sender":{"key":"cmn@elego.de","avatar":"https://avatars.githubusercontent.com/u/335443?v=4"},"body":"On Thu, 2011-07-14 at 18:10 +0530, J. Bakshi wrote:\n[...] snip snip snip\n> warning: You appear to have cloned an empty repository.\n> \n>  touch A\n>  git add A\n> \n>  git commit -m \"add A\"\n> \n> [master (root-commit) 7662edd] add A\n>  0 files changed, 0 insertions(+), 0 deletions(-)\n>  create mode 100644 A\n> \n>  git push\n>  Username:\n>  Password:\n>  Everything up-to-date\n> \n> \n> Why reports  [Everything up-to-date] rather than modify the remote git ?\n\nThat's because your remote repository has no branches and per default\ngit-push will only push matching branches; as no branches match, there\nis nothing to do. This is what \"warning: You appear to have cloned an\nempty repository.\" is trying to tell you (the message could certainly be\nmade much more friendly). Your master branch in this case doesn't exist\nin the server, so you have to tell git to push it explicitly.\n\n    git push origin master\n\nwill do the trick.\n\nCheers,\n   cmn\n"},{"id":"171395","messageId":"20110715105540.314304d1@shiva.selfip.org","threadId":"27814","inReplyTo":"1310647767.6041.73.camel@centaur.lab.cmartin.tk","subject":"Re: git with detached worktrees , push has no effect","fromName":"J. Bakshi","fromEmail":"joydeep@infoservices.in","sentAt":"2011-07-15T05:25:40Z","receivedAt":"2011-07-15T05:25:40Z","isPatch":false,"sender":{"key":"joydeep@infoservices.in","avatar":null},"body":"On Thu, 14 Jul 2011 14:49:27 +0200\nCarlos Martín Nieto <cmn@elego.de> wrote:\n\n> On Thu, 2011-07-14 at 18:10 +0530, J. Bakshi wrote:\n> [...] snip snip snip\n> > warning: You appear to have cloned an empty repository.\n> > \n> >  touch A\n> >  git add A\n> > \n> >  git commit -m \"add A\"\n> > \n> > [master (root-commit) 7662edd] add A\n> >  0 files changed, 0 insertions(+), 0 deletions(-)\n> >  create mode 100644 A\n> > \n> >  git push\n> >  Username:\n> >  Password:\n> >  Everything up-to-date\n> > \n> > \n> > Why reports  [Everything up-to-date] rather than modify the remote git ?\n> \n> That's because your remote repository has no branches and per default\n> git-push will only push matching branches; as no branches match, there\n> is nothing to do. This is what \"warning: You appear to have cloned an\n> empty repository.\" is trying to tell you (the message could certainly be\n> made much more friendly). Your master branch in this case doesn't exist\n> in the server, so you have to tell git to push it explicitly.\n> \n>     git push origin master\n> \n> will do the trick.\n> \n\nGRAET !!\n\nWorking like a charm and the hook is also working fine. Can we make the \nempty master branch at the server, so that client can continue with plain \"git push\" ?\n\nThanks\n"},{"id":"171396","messageId":"20110715105640.694fb3ea@shiva.selfip.org","threadId":"27814","inReplyTo":"1310647767.6041.73.camel@centaur.lab.cmartin.tk","subject":"Re: git with detached worktrees , push has no effect","fromName":"J. Bakshi","fromEmail":"joydeep@infoservices.in","sentAt":"2011-07-15T05:26:40Z","receivedAt":"2011-07-15T05:26:40Z","isPatch":false,"sender":{"key":"joydeep@infoservices.in","avatar":null},"body":"On Thu, 14 Jul 2011 14:49:27 +0200\nCarlos Martín Nieto <cmn@elego.de> wrote:\n\n> On Thu, 2011-07-14 at 18:10 +0530, J. Bakshi wrote:\n> [...] snip snip snip\n> > warning: You appear to have cloned an empty repository.\n> > \n> >  touch A\n> >  git add A\n> > \n> >  git commit -m \"add A\"\n> > \n> > [master (root-commit) 7662edd] add A\n> >  0 files changed, 0 insertions(+), 0 deletions(-)\n> >  create mode 100644 A\n> > \n> >  git push\n> >  Username:\n> >  Password:\n> >  Everything up-to-date\n> > \n> > \n> > Why reports  [Everything up-to-date] rather than modify the remote git ?\n> \n> That's because your remote repository has no branches and per default\n> git-push will only push matching branches; as no branches match, there\n> is nothing to do. This is what \"warning: You appear to have cloned an\n> empty repository.\" is trying to tell you (the message could certainly be\n> made much more friendly). Your master branch in this case doesn't exist\n> in the server, so you have to tell git to push it explicitly.\n> \n>     git push origin master\n> \n> will do the trick.\n> \n\nGreat !!\n\nWorking like a charm and the hook is also working fine. Can we make the \nempty master branch at the server, so that client can continue with plain \"git push\" ?\n\nThanks\n"},{"id":"171420","messageId":"1310757899.7308.10.camel@centaur.lab.cmartin.tk","threadId":"27814","inReplyTo":"20110715105640.694fb3ea@shiva.selfip.org","subject":"Re: git with detached worktrees , push has no effect","fromName":"Carlos Martín Nieto","fromEmail":"cmn@elego.de","sentAt":"2011-07-15T19:24:59Z","receivedAt":"2011-07-15T19:24:59Z","isPatch":false,"sender":{"key":"cmn@elego.de","avatar":"https://avatars.githubusercontent.com/u/335443?v=4"},"body":"On Fri, 2011-07-15 at 10:56 +0530, J. Bakshi wrote:\n[snip]\n> Working like a charm and the hook is also working fine. Can we make the \n> empty master branch at the server, so that client can continue with\n> plain \"git push\" ?\n\nYou may have figured this out already, but once you push, that branch\nexists, so under those same rules, pushing to master will work from\nthere onwards.\n\nIf you were asking whether you can create an empty branch on the remote\nyou it works \"automatically\", then the answer is no, because a branch\ndoesn't exist[0] before its first commit. A branch is a reference to a\ncommit (which is, logically, considered the tip of that branch). Thus an\nempty branch cannot exist before any commits are made to that branch.\n\n[0] For the purposes of network transfer. The way to create the first\ncommit ever in a repo (or in an orphan branch) is to have HEAD point to\nan as-of-yet nonexistent branch; but this won't help you in this case.\n\nCheers,\n   cmn\n\n"}]}