git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: how to add files/folder from work-tree

From
JBJ. Bakshi <joydeep@infoservices.in>
Date
Jul 20, 2011, 10:52 UTC
Message-ID
<20110720162208.3fa89d8b@shiva.selfip.org>
In-Reply-To
<20110720154644.67974a7f@shiva.selfip.org>

On Wed, 20 Jul 2011 15:46:44 +0530 "J. Bakshi" <joydeep@infoservices.in> wrote:

Show 52 quoted lines
> On Tue, 19 Jul 2011 20:13:08 +1200
> Chris Packham <judge.packham@gmail.com> wrote:
> 
> > Oops managed to drop the Cc for the mailing list from my initial response.
> > 
> > On 19/07/11 20:06, J. Bakshi wrote:
> > > On Tue, 19 Jul 2011 19:53:28 +1200
> > > Chris Packham <judge.packham@gmail.com> wrote:
> > > 
> > >> On 19/07/11 18:30, J. Bakshi wrote:
> > >>> Hello,
> > >>>
> > >>> I am using a git repo which has detached work tree. I like to add the files, folders located at the work tree ( it is a site under htdocs) at the git repo. Is it possible to do it within the work-tree or I need a separate working space from where I need to do all these operation ?
> > >>>
> > >>> Thanks
> > >>>  
> > >>> --
> > >>
> > >> I'm not sure I fully understand your question but what I _think_ you
> > >> want to do is specify the path to the repository with the GIT_DIR
> > >> environment variable. Like this
> > >>
> > >>  cd /place/where/files/are
> > >>  GIT_DIR=/place/were/repo/is/.git git add <file>
> > >>
> > > 
> > > 
> > > I have set a git repo with attached work-tree with hook as below
> > > 
> > > git -bare init  /home/git/test.git
> > > cd /home/git/test.git
> > > git config core.worktree /var/www/test
> > > 
> > > vim /home/git/test.git/hooks/post-receive
> > > 
> > > #!/bin/sh
> > > git checkout -f
> > > 
> > > Now the /var/www/test has already some files/folder. How can I add those to the repo within from its work-tree ?
> > > 
> > > Thanks
> > 
> > I think my initial response is correct. Try the following
> > 
> >   cd /var/www/test
> >   git --git-dir=/home/git/test.git add <files>
> 
> But this response as
> 
> ````
> fatal: This operation must be run in a work tree
> `````````
OK, need to append also --work-tree=/var/www/test
Previous: J. Bakshi
Message 5 of 5 in “how to add files/folder from work-tree”
  1. J. BakshiJul 19, 2011
  2. Chris PackhamJul 19, 2011
  3. J. BakshiJul 19, 2011
  4. J. BakshiJul 20, 2011
  5. J. BakshiJul 20, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.