# Correct way of making existing remote repository "bare"

7 messages from 2009-07-15 to 2009-07-16. Participants: Graeme Geldenhuys, Johannes Schindelin, Dirk Süsserott, Junio C Hamano, Eric Raible.
Thread: https://gitlist.dev/t/20119

## Graeme Geldenhuys, 2009-07-15 12:20

Subject: Correct way of making existing remote repository "bare"
Message-ID: <h3khis$3tq$1@ger.gmane.org>
URL: https://gitlist.dev/e/h3khis%243tq%241%40ger.gmane.org

```
Hi,

Yesterday I initialized a new repository on our server. I did some 
coding locally, added the remote server (git remote add ....) and then 
pushed my changes to the remote server.

But I noticed that my remote server is not a "bare" repository and git 
complains when I push to it again. What is the correct way to make an 
existing remote repository bare?

This is what I did and it worked, but not sure if this is the correct 
way of doing it.

Steps I done:

* ssh to remote server
* git clone --bare -l <path_to_repos> <new_dir>
* renamed old repository directory
* renamed new repository dir to what old repository used to be.

Like I said, this did the tick, but is this the correct way of doing it?


Regards,
   - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://opensoft.homeip.net/fpgui/

```

## Johannes Schindelin, 2009-07-15 14:08

Subject: Re: Correct way of making existing remote repository "bare"
Message-ID: <alpine.DEB.1.00.0907151607050.4410@intel-tinevez-2-302>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0907151607050.4410%40intel-tinevez-2-302
In-Reply-To: <h3khis$3tq$1@ger.gmane.org>

```
Hi,

On Wed, 15 Jul 2009, Graeme Geldenhuys wrote:

> Steps I done:
> 
> * ssh to remote server
> * git clone --bare -l <path_to_repos> <new_dir>
> * renamed old repository directory
> * renamed new repository dir to what old repository used to be.
> 
> Like I said, this did the tick, but is this the correct way of doing it?

That's the easiest.  However, I regularly avoid those steps by doing

	mv bla/.git bla.git
	git --git-dir=bla.git config core.bare true
	rm -rf bla

This requires a bit more familiarity with the Git internals than your 
solution, though (although it makes sure that the config is unchanged, as 
well as possibly installed hooks).

Ciao,
Dscho

```

## Dirk Süsserott, 2009-07-15 14:12

Subject: Re: Correct way of making existing remote repository "bare"
Message-ID: <4A5DE3DA.1010004@dirk.my1.cc>
URL: https://gitlist.dev/e/4A5DE3DA.1010004%40dirk.my1.cc
In-Reply-To: <h3khis$3tq$1@ger.gmane.org>

```
Am 15.07.2009 14:20 schrieb Graeme Geldenhuys:
> Hi,
> 
> Yesterday I initialized a new repository on our server. I did some 
> coding locally, added the remote server (git remote add ....) and then 
> pushed my changes to the remote server.
> 
> But I noticed that my remote server is not a "bare" repository and git 
> complains when I push to it again. What is the correct way to make an 
> existing remote repository bare?
> 
> This is what I did and it worked, but not sure if this is the correct 
> way of doing it.
> 
> Steps I done:
> 
> * ssh to remote server
> * git clone --bare -l <path_to_repos> <new_dir>
> * renamed old repository directory
> * renamed new repository dir to what old repository used to be.
> 
> Like I said, this did the tick, but is this the correct way of doing it?
> 
> 
> Regards,
>   - Graeme -
> 

Sounds like that's the correct way. I sometimes faced the same problem 
and was lazy:

$ ssh to the remote && cd repo
$ rm everything except for the .git directory (make sure everything is 
committed before doing this)
$ mv .git/* . && rmdir .git # i.e.move the .git contents one level up
$ edit config
change 'core.bare=false' to 'core.bare=true' (or add a similar line)

done.

I think what you did is 'porcellain' while my solution is 'plumbing'.
Any complaints?

     Dirk

```

## Dirk Süsserott, 2009-07-15 14:21

Subject: Re: Correct way of making existing remote repository "bare"
Message-ID: <4A5DE5FD.80304@dirk.my1.cc>
URL: https://gitlist.dev/e/4A5DE5FD.80304%40dirk.my1.cc
In-Reply-To: <alpine.DEB.1.00.0907151607050.4410@intel-tinevez-2-302>

```
Am 15.07.2009 16:08 schrieb Johannes Schindelin:
> Hi,
> 
> On Wed, 15 Jul 2009, Graeme Geldenhuys wrote:
> 
>> Steps I done:
>>
>> * ssh to remote server
>> * git clone --bare -l <path_to_repos> <new_dir>
>> * renamed old repository directory
>> * renamed new repository dir to what old repository used to be.
>>
>> Like I said, this did the tick, but is this the correct way of doing it?
> 
> That's the easiest.  However, I regularly avoid those steps by doing
> 
> 	mv bla/.git bla.git
> 	git --git-dir=bla.git config core.bare true
> 	rm -rf bla
> 
> This requires a bit more familiarity with the Git internals than your 
> solution, though (although it makes sure that the config is unchanged, as 
> well as possibly installed hooks).
> 

Dscho, you boiled down my solution to real git commands. Great. -- Dirk

```

## Graeme Geldenhuys, 2009-07-15 14:44

Subject: Re: Correct way of making existing remote repository "bare"
Message-ID: <h3kq06$vml$1@ger.gmane.org>
URL: https://gitlist.dev/e/h3kq06%24vml%241%40ger.gmane.org
In-Reply-To: <alpine.DEB.1.00.0907151607050.4410@intel-tinevez-2-302>

```
Johannes Schindelin wrote:
> 
> That's the easiest.  However, I regularly avoid those steps by doing

Thanks Johannes and Dirk. I'll make a not of this.

Maybe somebody could add this to some Git FAQ?  I did some Google'ing 
and didn't find any documentation on this (well nothing blatantly visible).


Regards,
   - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://opensoft.homeip.net/fpgui/

```

## Junio C Hamano, 2009-07-15 19:39

Subject: Re: Correct way of making existing remote repository "bare"
Message-ID: <7vws69enws.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vws69enws.fsf%40alter.siamese.dyndns.org
In-Reply-To: <4A5DE3DA.1010004@dirk.my1.cc>

```
Dirk Süsserott <newsletter@dirk.my1.cc> writes:

> I think what you did is 'porcellain' while my solution is 'plumbing'.
> Any complaints?

No.

We need to be careful and either (1) to have anybody who adds 'plumbing'
procedure to any FAQ responsible for keeping it up to date, as the
implementation detail is subject to change, or (2) only to have
'Porcelain' description in the documentation.

```

## Eric Raible, 2009-07-16 07:59

Subject: Re: Correct way of making existing remote repository "bare"
Message-ID: <loom.20090716T074910-226@post.gmane.org>
URL: https://gitlist.dev/e/loom.20090716T074910-226%40post.gmane.org
In-Reply-To: <alpine.DEB.1.00.0907151607050.4410@intel-tinevez-2-302>

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

> That's the easiest.  However, I regularly avoid those steps by doing
> 
> 	mv bla/.git bla.git
> 	git --git-dir=bla.git config core.bare true
> 	rm -rf bla
> 

Is it simpler and more complete to do this?

	git config core.bare true
	git config core.logAllRefUpdates
	mv bla/.git bla.git
	rm -rf bla

```
