Skip to contentSkip to conversation

how to add files/folder from work-tree

DISCUSSION J. Bakshi 2 participants 5 messages Jun 15, 2016 2 messages not in the archive

lore
Share & tools
lore

J. Bakshi

author
#0 lore raw

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

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw

Oops managed to drop the Cc for the mailing list from my initial response.

Quoted 27 lines · J. Bakshi
Quoted 7 lines · On Tue, 19 Jul 2011 19:53:28 +1200 Chris Packham <[email protected]>…
Quoted 6 lines · J. Bakshi

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

Quoted 9 lines
Quoted 1 line

--

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

Quoted 8 lines

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>
  git --git-dir=/home/git/test.git commit -m "blah"
author
#4 lore raw
Quoted 37 lines · On Tue, 19 Jul 2011 20:13:08 +1200 Chris Packham <[email protected]>…

Oops managed to drop the Cc for the mailing list from my initial response.

Quoted 34 lines · J. Bakshi
Quoted 7 lines · On Tue, 19 Jul 2011 19:53:28 +1200 Chris Packham <[email protected]>…
Quoted 6 lines · J. Bakshi

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

Quoted 9 lines
Quoted 1 line

--

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 ?

Quoted 9 lines
Quoted 1 line

Thanks

I think my initial response is correct. Try the following

  cd /var/www/test
  git --git-dir=/home/git/test.git add <files>
  git --git-dir=/home/git/test.git commit -m "blah"

Great !! Thanks

author
#5 lore raw
In reply to Chris Packham
Quoted 35 lines · On Tue, 19 Jul 2011 20:13:08 +1200 Chris Packham <[email protected]>…

Oops managed to drop the Cc for the mailing list from my initial response.

Quoted 32 lines · J. Bakshi
Quoted 7 lines · On Tue, 19 Jul 2011 19:53:28 +1200 Chris Packham <[email protected]>…
Quoted 6 lines · J. Bakshi

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

Quoted 9 lines
Quoted 1 line

--

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

Quoted 8 lines
Quoted 3 lines

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
`````````
author
#6 lore raw
Quoted 44 lines · On Wed, 20 Jul 2011 15:46:44 +0530 "J. Bakshi" <[email protected]> wrote:
Quoted 41 lines · On Tue, 19 Jul 2011 20:13:08 +1200 Chris Packham <[email protected]>…

Oops managed to drop the Cc for the mailing list from my initial response.

Quoted 27 lines · J. Bakshi
Quoted 7 lines · On Tue, 19 Jul 2011 19:53:28 +1200 Chris Packham <[email protected]>…
Quoted 6 lines · J. Bakshi

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

Quoted 9 lines
Quoted 1 line

--

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

Quoted 8 lines

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

Quoted 8 lines
Quoted 2 lines
  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