threads / discuss / 20516

.gitignore vs untracked working file

Subject: .gitignore vs untracked working file

## tl;dr

7 messages between Aug 10, 2009 and Aug 10, 2009.

replies: 6people: 3as markdown or json

Rostislav Svoboda· Aug 10, 2009, 09:57 UTC · lore
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· Aug 10, 2009, 10:01 UTC · re: Rostislav Svoboda · lore

Re: .gitignore vs untracked working file

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· Aug 10, 2009, 10:17 UTC · re: Uwe Kleine-König · lore

Re: .gitignore vs untracked working file

2009/8/10 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>:
Show 8 quoted lines
> 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· Aug 10, 2009, 11:41 UTC · re: Rostislav Svoboda · lore

Re: .gitignore vs untracked working file

Rostislav Svoboda schrieb:
Show 11 quoted lines
> 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· Aug 10, 2009, 12:59 UTC · re: Johannes Sixt · lore

Re: .gitignore vs untracked working file

2009/8/10 Johannes Sixt <j.sixt@viscovery.net>:
Show 16 quoted lines
> 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· Aug 10, 2009, 13:14 UTC · re: Rostislav Svoboda · lore

Re: .gitignore vs untracked working file

Rostislav Svoboda schrieb:
Show 9 quoted lines
> $ 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· Aug 10, 2009, 13:49 UTC · re: Johannes Sixt · lore

Re: .gitignore vs untracked working file

Show 5 quoted lines
> 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 :-)

← back to recent threads