# .gitignore vs untracked working file

7 messages from 2009-08-10 to 2009-08-10. Participants: Rostislav Svoboda, Uwe Kleine-König, Johannes Sixt.
Thread: https://gitlist.dev/t/20516

## Rostislav Svoboda, 2009-08-10 09:57

Subject: .gitignore vs untracked working file
Message-ID: <286817520908100257n35b178ebu387161658554b4a@mail.gmail.com>
URL: https://gitlist.dev/e/286817520908100257n35b178ebu387161658554b4a%40mail.gmail.com

```
Hi

I have a .gitignore rule to ignore everything in bin/ directories but
I cannot change branch because of a file lying in a bin/ directory
which actually should be ignored. What am I doing wrong?

$ git branch
  master
* mybranch

$ git status
# On branch mybranch
nothing to commit (working directory clean)

$ cat .gitignore
*.class
.cvsignore
CVS/
.metadata/
build/
bin/
.#*

$ git checkout master
error: Untracked working tree file 'Project/bin/path/file.jjt' would
be overwritten by merge.

$ git --version
git version 1.6.4.msysgit.0


thx

Bost

```

## Uwe Kleine-König, 2009-08-10 10:01

Subject: Re: .gitignore vs untracked working file
Message-ID: <20090810100148.GB22200@pengutronix.de>
URL: https://gitlist.dev/e/20090810100148.GB22200%40pengutronix.de
In-Reply-To: <286817520908100257n35b178ebu387161658554b4a@mail.gmail.com>

```
Hello,

> $ git checkout master
> error: Untracked working tree file 'Project/bin/path/file.jjt' would
> be overwritten by merge.
What is the output of

	$ git ls-files master bin/

?

Best regards
Uwe

-- 
Pengutronix e.K.                              | Uwe Kleine-König            |
Industrial Linux Solutions                    | http://www.pengutronix.de/  |

```

## Rostislav Svoboda, 2009-08-10 10:17

Subject: Re: .gitignore vs untracked working file
Message-ID: <286817520908100317k4e98faf9n4e852b7abd4719fe@mail.gmail.com>
URL: https://gitlist.dev/e/286817520908100317k4e98faf9n4e852b7abd4719fe%40mail.gmail.com
In-Reply-To: <20090810100148.GB22200@pengutronix.de>

```
2009/8/10 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>:
> Hello,
>
>> $ git checkout master
>> error: Untracked working tree file 'Project/bin/path/file.jjt' would
>> be overwritten by merge.
> What is the output of
>
>        $ git ls-files master bin/

Nothing:

$ git ls-files master bin/
$ git ls-files master Project/bin/
$ git ls-files mybranch bin/
$ git ls-files mybranch Project/bin/

$ ll 'Project/bin/path/file.jjt'
-rw-r--r--    1 bost  Administ     8233 May 10  2006 Project/bin/path/file.jjt
$ git ls-files ''Project/bin/path/file.jjt'

BTW the rule to ignore bin/ is exclusively in the .gitignore on the
branch mybranch not in the master branch. Might this be the problem?

Bost

```

## Johannes Sixt, 2009-08-10 11:41

Subject: Re: .gitignore vs untracked working file
Message-ID: <4A800785.8050909@viscovery.net>
URL: https://gitlist.dev/e/4A800785.8050909%40viscovery.net
In-Reply-To: <286817520908100317k4e98faf9n4e852b7abd4719fe@mail.gmail.com>

```
Rostislav Svoboda schrieb:
> 2009/8/10 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>:
>> Hello,
>>
>>> $ git checkout master
>>> error: Untracked working tree file 'Project/bin/path/file.jjt' would
>>> be overwritten by merge.
>> What is the output of
>>
>>        $ git ls-files master bin/
> 
> Nothing:

It should have been

	$ git ls-tree master bin

> BTW the rule to ignore bin/ is exclusively in the .gitignore on the
> branch mybranch not in the master branch. Might this be the problem?

It might be, depending on how precious Project/bin/path/file.jjt is for
you. Try this:

	$ git checkout -f master

This will overwrite the existing file with the version from master. If you
later

	$ git checkout mybranch

then the file will be *removed*.

-- Hannes

```

## Rostislav Svoboda, 2009-08-10 12:59

Subject: Re: .gitignore vs untracked working file
Message-ID: <286817520908100559u6cdcaab0u3a7fdb92cd43eed9@mail.gmail.com>
URL: https://gitlist.dev/e/286817520908100559u6cdcaab0u3a7fdb92cd43eed9%40mail.gmail.com
In-Reply-To: <4A800785.8050909@viscovery.net>

```
2009/8/10 Johannes Sixt <j.sixt@viscovery.net>:
> Rostislav Svoboda schrieb:
>> 2009/8/10 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>:
>>> Hello,
>>>
>>>> $ git checkout master
>>>> error: Untracked working tree file 'Project/bin/path/file.jjt' would
>>>> be overwritten by merge.
>>> What is the output of
>>>
>>>        $ git ls-files master bin/
>>
>> Nothing:
>
> It should have been
>
>        $ git ls-tree master bin

Merde!

$ git ls-tree master Project/bin/path/file.jjt
100644 blob 8d5e24f12c37fd1a435de2d4402591f5b0c2a3cc
Project/bin/path/file.jjt

There's a file.jjt in the repo already! But guys! I bet I'm not the
first one having this problem. Do you think it would be wise to have a
kind of a check returning
    'The file '...' ignored in the branch X is not ignored in the
branch Y (or something)'

instead of responding questions like mine over and over again?

Bost

PS: ... and yea, thx a lot!

```

## Johannes Sixt, 2009-08-10 13:14

Subject: Re: .gitignore vs untracked working file
Message-ID: <4A801D48.3020902@viscovery.net>
URL: https://gitlist.dev/e/4A801D48.3020902%40viscovery.net
In-Reply-To: <286817520908100559u6cdcaab0u3a7fdb92cd43eed9@mail.gmail.com>

```
Rostislav Svoboda schrieb:
> $ git ls-tree master Project/bin/path/file.jjt
> 100644 blob 8d5e24f12c37fd1a435de2d4402591f5b0c2a3cc
> Project/bin/path/file.jjt
> 
> There's a file.jjt in the repo already! But guys! I bet I'm not the
> first one having this problem. Do you think it would be wise to have a
> kind of a check returning
>     'The file '...' ignored in the branch X is not ignored in the
> branch Y (or something)'

This is not only about ignored files, but untracked files. And the check
is already there: git said:

Untracked working tree file 'Project/bin/path/file.jjt' would be
overwritten by merge.

-- Hannes

```

## Rostislav Svoboda, 2009-08-10 13:49

Subject: Re: .gitignore vs untracked working file
Message-ID: <286817520908100649j4d369a10p22c667ee077daa47@mail.gmail.com>
URL: https://gitlist.dev/e/286817520908100649j4d369a10p22c667ee077daa47%40mail.gmail.com
In-Reply-To: <4A801D48.3020902@viscovery.net>

```
> This is not only about ignored files, but untracked files. And the check
> is already there: git said:
>
> Untracked working tree file 'Project/bin/path/file.jjt' would be
> overwritten by merge.

Well the meaning of the error message is clear to you but it wasn't
for me. I simply would not ask if I knew how to correctly interpret
it. I hope I'll have a time to make a little improvement here...

Bost

PS: ...and you can reject it if you don't agree :-)

```
