# Merging a foreign tree into a bare repository.

6 messages from 2008-07-09 to 2008-07-09. Participants: Dave Quigley, Johannes Schindelin, Alejandro Riveira, Jakub Narebski, Eric Raible.
Thread: https://gitlist.dev/t/14361

## Dave Quigley, 2008-07-09 00:14

Subject: Merging a foreign tree into a bare repository.
Message-ID: <1215562468.4199.26.camel@moss-terrapins.epoch.ncsc.mil>
URL: https://gitlist.dev/e/1215562468.4199.26.camel%40moss-terrapins.epoch.ncsc.mil

```
Hello,
   I created a bare copy of Linus' 2.6 kernel tree which I am using for
some public development. I have a branch in this tree called patchset
which has a series of commits based on a patch set that I have. Now I
want to update this copy from the kernel.org git repository and rebase
the patches in the patchset branch. I typed git-fetch <URL to Linus'
tree> and it successfully fetched the remote objects. I tried to then
merge them but you need a working directory to merge the changes which
makes sense. Normally if I had a working directory I would use
git-rebase to rebase my patches on a working tree but since this is a
bare repository I can't do that. How would one go about doing this with
a bare repository? Is there a better way of doing this that I am not
aware of? Is my work flow completely off?

Dave

```

## Johannes Schindelin, 2008-07-09 00:40

Subject: Re: Merging a foreign tree into a bare repository.
Message-ID: <alpine.DEB.1.00.0807090238561.5277@eeepc-johanness>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0807090238561.5277%40eeepc-johanness
In-Reply-To: <1215562468.4199.26.camel@moss-terrapins.epoch.ncsc.mil>

```
Hi,

On Tue, 8 Jul 2008, Dave Quigley wrote:

> I tried to then merge them but you need a working directory to merge the 
> changes which makes sense.

Of course it does.  Merging runs the risk of conflicts, and you need a 
working directory for that.

> How would one go about doing this with a bare repository?

Very easy: clone it ("non-barely"), merge, and push back the results.

You _need_ a working directory for the merge.

Hth,
Dscho "who wonders what No Such Agency does with Git..."

```

## Alejandro Riveira, 2008-07-09 14:25

Subject: Re: Merging a foreign tree into a bare repository.
Message-ID: <g52ho5$1eo$1@ger.gmane.org>
URL: https://gitlist.dev/e/g52ho5%241eo%241%40ger.gmane.org
In-Reply-To: <alpine.DEB.1.00.0807090238561.5277@eeepc-johanness>

```
El Wed, 09 Jul 2008 02:40:52 +0200, Johannes Schindelin escribió:


> 
> Hth,
> Dscho "who wonders what No Such Agency does with Git..."

 SELinux development ?? :P

```

## Jakub Narebski, 2008-07-09 17:27

Subject: Re: Merging a foreign tree into a bare repository.
Message-ID: <m3lk0bdkyl.fsf@localhost.localdomain>
URL: https://gitlist.dev/e/m3lk0bdkyl.fsf%40localhost.localdomain
In-Reply-To: <alpine.DEB.1.00.0807090238561.5277@eeepc-johanness>

```
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> On Tue, 8 Jul 2008, Dave Quigley wrote:
> 
> > I tried to then merge them but you need a working directory to merge the 
> > changes which makes sense.
> 
> Of course it does.  Merging runs the risk of conflicts, and you need a 
> working directory for that.
> 
> > How would one go about doing this with a bare repository?
> 
> Very easy: clone it ("non-barely"), merge, and push back the results.
> 
> You _need_ a working directory for the merge.

Or, alternatively, you can tell git where you want to have working
directory with '--work-tree' parameter to git wrapper, for example

  1451:jnareb@roke:/tmp/jnareb> git clone --bare test/ test-clone.git
  Initialize test-clone.git
  Initialized empty Git repository in /tmp/jnareb/test-clone.git/

(Hmmm... I hope the last message, which is unnecessary and I think
is just spillage from git-init, would vanish in builting git-clone)

  1453:jnareb@roke:/tmp/jnareb/test-clone.git> ls
  branches  config  description  HEAD  hooks  info  objects  refs
  1454:jnareb@roke:/tmp/jnareb/test-clone.git> cat config 
  [core]
        repositoryformatversion = 0
        filemode = true
        bare = true

(It is bare repository)
  
  1461:jnareb@roke:/tmp/jnareb/test-clone.git> git checkout
  fatal: This operation must be run in a work tree

(You would get the same error with merge and with rebase)

  1458:jnareb@roke:/tmp/jnareb/test-clone.git> git --work-tree=../test-workdir/ checkout
  1459:jnareb@roke:/tmp/jnareb/test-clone.git> ls ../test-workdir/
  foo

It works!

You can also set core.worktree configuration variable... although
I don't know what git would do if core.bare is true and core.worktree
is set.

HTH
-- 
Jakub Narebski
Poland
ShadeHawk on #git

```

## Johannes Schindelin, 2008-07-09 18:42

Subject: Re: Merging a foreign tree into a bare repository.
Message-ID: <alpine.DEB.1.00.0807092040360.4010@eeepc-johanness>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0807092040360.4010%40eeepc-johanness
In-Reply-To: <m3lk0bdkyl.fsf@localhost.localdomain>

```
Hi,

On Wed, 9 Jul 2008, Jakub Narebski wrote:

> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > On Tue, 8 Jul 2008, Dave Quigley wrote:
> > 
> > > I tried to then merge them but you need a working directory to merge the 
> > > changes which makes sense.
> > 
> > Of course it does.  Merging runs the risk of conflicts, and you need a 
> > working directory for that.
> > 
> > > How would one go about doing this with a bare repository?
> > 
> > Very easy: clone it ("non-barely"), merge, and push back the results.
> > 
> > You _need_ a working directory for the merge.
> 
> Or, alternatively, you can tell git where you want to have working
> directory with '--work-tree' parameter to git wrapper,

... which runs the risk of you forgetting to specify the same working 
directory all the time.

Which is the reason I did not suggest it.

> You can also set core.worktree configuration variable...

... effectively turning it into a non-bare repository.  Was that the 
question, how to turn a bare repository into a non-bare one?

Ciao,
Dscho

```

## Eric Raible, 2008-07-09 21:04

Subject: Re: Merging a foreign tree into a bare repository.
Message-ID: <loom.20080709T205908-869@post.gmane.org>
URL: https://gitlist.dev/e/loom.20080709T205908-869%40post.gmane.org
In-Reply-To: <alpine.DEB.1.00.0807092040360.4010@eeepc-johanness>

```
Johannes Schindelin <Johannes.Schindelin <at> gmx.de> writes:
> 
> Hi,
> 
> On Wed, 9 Jul 2008, Jakub Narebski wrote:
> > 
> > Or, alternatively, you can tell git where you want to have working
> > directory with '--work-tree' parameter to git wrapper,
> 
> ... which runs the risk of you forgetting to specify the same working 
> directory all the time.
> 
> Which is the reason I did not suggest it.

How about:

GIT_WORK_TREE=<some-dir>; export GIT_WORK_TREE

Combined with a PS1 which include an indication that GIT_WORK_TREE is set?

- Eric

```
