threads / discuss / 14361

Merging a foreign tree into a bare repository.

Subject: Merging a foreign tree into a bare repository.

## tl;dr

6 messages between Jul 9, 2008 and Jul 9, 2008.

replies: 5people: 5as markdown or json

Dave Quigley· Jul 9, 2008, 00:14 UTC · lore
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· Jul 9, 2008, 00:40 UTC · re: Dave Quigley · lore

Re: Merging a foreign tree into a bare repository.

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..."

Jakub Narebski· Jul 9, 2008, 17:27 UTC · re: Johannes Schindelin · lore

Re: Merging a foreign tree into a bare repository.

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 13 quoted lines
> 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· Jul 9, 2008, 18:42 UTC · re: Jakub Narebski · lore

Re: Merging a foreign tree into a bare repository.

Hi,
On Wed, 9 Jul 2008, Jakub Narebski wrote:
Show 18 quoted lines
> 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· Jul 9, 2008, 21:04 UTC · re: Johannes Schindelin · lore

Re: Merging a foreign tree into a bare repository.

Johannes Schindelin <Johannes.Schindelin <at> gmx.de> writes:
Show 12 quoted lines
> 
> 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

← back to recent threads