Git repository on USB?

133 views
Skip to first unread message

Will Rocisky

unread,
Apr 8, 2008, 2:49:23 AM4/8/08
to msysGit
I want to create a git repository on USB where I can push to and pull
from.
Is it possible?

Johannes Schindelin

unread,
Apr 8, 2008, 5:56:43 AM4/8/08
to Will Rocisky, msysGit
Hi,

On Mon, 7 Apr 2008, Will Rocisky wrote:

> I want to create a git repository on USB where I can push to and pull
> from. Is it possible?

Not only possible. I do it all the time. But please do not make the
error of using a non-bare repository there.

Ciao,
Dscho

Junio C Hamano

unread,
Apr 8, 2008, 3:22:23 PM4/8/08
to Johannes....@gmx.de, Will Rocisky, msysGit
Johannes Schindelin <Johannes....@gmx.de> writes:

Why not?

Tim Harper

unread,
Apr 8, 2008, 3:27:30 PM4/8/08
to msy...@googlegroups.com, Junio C Hamano
I think he's saying "Not only is it possible, but I do it all the
time". Not, "not possible".

:)

Junio C Hamano

unread,
Apr 8, 2008, 3:50:18 PM4/8/08
to timch...@gmail.com, msy...@googlegroups.com
Tim Harper <timch...@gmail.com> writes:

I think I was asking why not a non-bare repository there.

Johannes Schindelin

unread,
Apr 9, 2008, 9:06:57 AM4/9/08
to Junio C Hamano, Will Rocisky, msysGit
Hi,

IIRC there was the famous "HEAD" vs "head" problem.

Also, the index is prone to get out of sync when accessing the USB drive
from different Operating Systems, since the inode information is
different.

Which means that earlier, the files appeared changed whenever accessing
them from another OS, and now with the automatic index updating, actions
take much longer.

Ciao,
Dscho

Junio C Hamano

unread,
Apr 9, 2008, 6:05:45 PM4/9/08
to Johannes....@gmx.de, Will Rocisky, msysGit
Johannes Schindelin <Johannes....@gmx.de> writes:

> On Tue, 8 Apr 2008, Junio C Hamano wrote:
>
>> Johannes Schindelin <Johannes....@gmx.de> writes:
>>
>> > On Mon, 7 Apr 2008, Will Rocisky wrote:
>> >
>> >> I want to create a git repository on USB where I can push to and pull
>> >> from. Is it possible?
>> >
>> > Not only possible. I do it all the time. But please do not make the
>> > error of using a non-bare repository there.
>>
>> Why not?
>
> IIRC there was the famous "HEAD" vs "head" problem.

How does "a bare repository" make that irrelevent?

Also the original question just talked about "USB". I think there are USB
harddisks these days ;-)

Johannes Schindelin

unread,
Apr 10, 2008, 7:21:49 AM4/10/08
to Junio C Hamano, Will Rocisky, msysGit
Hi,

On Wed, 9 Apr 2008, Junio C Hamano wrote:

> Johannes Schindelin <Johannes....@gmx.de> writes:
>
> > On Tue, 8 Apr 2008, Junio C Hamano wrote:
> >
> >> Johannes Schindelin <Johannes....@gmx.de> writes:
> >>
> >> > On Mon, 7 Apr 2008, Will Rocisky wrote:
> >> >
> >> >> I want to create a git repository on USB where I can push to and
> >> >> pull from. Is it possible?
> >> >
> >> > Not only possible. I do it all the time. But please do not make
> >> > the error of using a non-bare repository there.
> >>
> >> Why not?
> >
> > IIRC there was the famous "HEAD" vs "head" problem.
>
> How does "a bare repository" make that irrelevent?

It is irrelevant for bare repositories, because you do not typically work
with anything HEAD related in them. You just push and fetch specific
branches, at least that is what I do.

> Also the original question just talked about "USB". I think there are
> USB harddisks these days ;-)

Yes, and I even have one which is formatted as ReiserFS. Good point.

But I still have USB sticks that I use to share data between different
operating systems (notably Windows, since that is still the most
complicated and error-prone OS in terms of networking that I know). And
that's what I assumed of the OP as well.

Ciao,
Dscho

Mikew

unread,
May 21, 2008, 7:16:40 AM5/21/08
to msysGit, Johannes....@gmx.de
Hi All, Dscho,

On Apr 8, 7:56 pm, Johannes Schindelin <Johannes.Schinde...@gmx.de>
wrote:
So how do you do it? (ie what do you type to clone to a removable USB
stick using msysgit)
In otherwords, How can I specify a removable drive as the location for
the bare clone?

Here is what I have tried using Git-1.5.5-preview20080413.exe, ie git
version 1.5.5.1015.g9d258, installed using the "Use Git Bash Only"
option.

Insert USB stick which is mounted by windows as drive E: (As seen/
verified in windows file explorer)

Start Git Bash using quick launch icon.
mwake@L201263 ~
$ mkdir -p /c/git_work/fixed_drive

mwake@L201263 ~
$ cd /c/git_work/fixed_drive

mwake@L201263 /c/git_work/fixed_drive
$ git init
Initialized empty Git repository in .git/

mwake@L201263 /c/git_work/fixed_drive
$ echo "hello" > hello.txt

mwake@L201263 /c/git_work/fixed_drive
$ git add hello.txt

mwake@L201263 /c/git_work/fixed_drive
$ git commit -m "Initial Version"

So far so good. Now attempt to clone it to the removable usb key.

mwake@L201263 /c/git_work/fixed_drive
$ cd /c/git_work

mwake@L201263 /c/git_work
$ git clone --bare fixed_drive /e/removable_drive
Initialized empty Git repository in C:/Program Files/Git/e/
removable_drive/

Hmmm :-/ Not what I wanted or expected.

mwake@L201263 /c/git_work
$ git clone --bare fixed_drive e:/removable_drive
Initialized empty Git repository in c:/git_work/e/removable_drive/

Hmmmmmm :/ Still not what I wanted or expected.

How can I refer to a removable drive?
mwake@L201263 /c/git_work
$ cd /e
sh.exe": cd: /e: No such file or directory

mwake@L201263 /c/git_work
$ cd /E
sh.exe": cd: /E: No such file or directory

!!!! I initially thought this next one was interesting and may be a
clue in the right hands !!!

mwake@L201263 /c/git_work
$ cd e:
mwake@L201263 e

Notice that the Prompt is missing the leading /

But if you look above at the creation of a clone in an unintended
location, there is an "e" directory in C:/Program Files/Git

Hope this level of detail is not too much and helps highlight the
problem

Cheers
Mikew.

Johannes Schindelin

unread,
May 21, 2008, 7:35:26 AM5/21/08
to Mikew, msysGit
Hi,

On Wed, 21 May 2008, Mikew wrote:

> On Apr 8, 7:56 pm, Johannes Schindelin <Johannes.Schinde...@gmx.de>

Blast from the past!

> mwake@L201263 /c/git_work
> $ git clone --bare fixed_drive /e/removable_drive

Why not rather

$ cd /e/
$ git clone --bare /c/git_work/fixed_drive removable_drive

Hmm?

Ciao,
Dscho

mike wake

unread,
May 21, 2008, 9:21:50 AM5/21/08
to Johannes Schindelin, msysGit
On Wed, May 21, 2008 at 9:35 PM, Johannes Schindelin
<Johannes....@gmx.de> wrote:
> Hi,
>
> On Wed, 21 May 2008, Mikew wrote:
>
>> On Apr 8, 7:56 pm, Johannes Schindelin <Johannes.Schinde...@gmx.de>
>
> Blast from the past!
Heh.

>> mwake@L201263 /c/git_work
>> $ git clone --bare fixed_drive /e/removable_drive
>
> Why not rather
>
> $ cd /e/
> $ git clone --bare /c/git_work/fixed_drive removable_drive
>
> Hmm?

Nope. cd /e/ doesn't work here either.

mwake@L201263 ~
$ cd /e/
sh.exe": cd: /e/: No such file or directory


Mikew.

Johannes Schindelin

unread,
May 21, 2008, 9:25:29 AM5/21/08
to mike wake, msysGit
Hi,

On Wed, 21 May 2008, mike wake wrote:

> Nope. cd /e/ doesn't work here either.
>
> mwake@L201263 ~
> $ cd /e/
> sh.exe": cd: /e/: No such file or directory

The wonders of Microsoft. You need to open the Bash _after_ your USB
drive was properly recognized.

Hth,
Dscho

mike wake

unread,
May 21, 2008, 9:40:02 AM5/21/08
to Johannes Schindelin, msysGit
On Wed, May 21, 2008 at 11:25 PM, Johannes Schindelin
<Johannes....@gmx.de> wrote:
>> Nope. cd /e/ doesn't work here either.
>>
>> mwake@L201263 ~
>> $ cd /e/
>> sh.exe": cd: /e/: No such file or directory
>
> The wonders of Microsoft.
Tell me about it!

> You need to open the Bash _after_ your USB
> drive was properly recognized.

Tried that too. Same result here. Does it work for you?

I can "cd /cygdrive/e" in a cygwin bash shell.

I can get to the drive by typing "e:/" in a cmd shell

Git Bash, on my computer at least, has a problem getting to USB drives.

I have some partitions M: and N: as well as a CDROM drive D: that Git
Bash can cd into.
ie The following all work
cd /d
cd /m
cd /n
cd d:
cd m:
cd n:

Three finger salute coming up to see if that clears it.

Cheers
Mikew.

mike wake

unread,
May 21, 2008, 9:55:50 AM5/21/08
to Johannes Schindelin, msysGit
> Three finger salute coming up to see if that clears it.
>
Hmmm a reboot cleared the problem of not being able to cd to a USB
drive from a Git Bash shell. I hate it when that happens.

Next time, if there is one, I'll try looking for some stray processes to kill.

Cheers
Mikew.

Shak

unread,
Jun 7, 2008, 5:14:20 AM6/7/08
to msy...@googlegroups.com
"Johannes Schindelin" <Johannes....@gmx.de> wrote in message
news:alpine.DEB.1.00.0804081056140.430@eeepc-johanness...


What exactly is a non-bare repository?

Shak


Jim Raden

unread,
Jun 7, 2008, 10:23:23 AM6/7/08
to Shak, msy...@googlegroups.com
To quote someone who explains it better than me:

"A bare repository is one without a checked out working copy of the code. It only contains the git database.... To ensure this doesn't happen, we're making the server repository a bare repository - it has no working copy." http://www.bluishcoder.co.nz/2007/09/how-to-publish-git-repository.html

Contrast that with Subversion, where the repository is *always* bare in the Git sense.
Reply all
Reply to author
Forward
0 new messages