threads / discuss / 16522

Overwriting untracked working tree files (when identical)

Subject: Overwriting untracked working tree files (when identical)

## tl;dr

2 messages between Nov 29, 2008 and Dec 1, 2008.

replies: 1people: 2as markdown or json

Asheesh Laroia· Nov 29, 2008, 18:58 UTC · lore
I was using git earlier today and got the familiar error:
 	"Untracked working tree file 'filename’ would be overwritten by merge"

As it happens, I know that filename in my local filesystem and filename in the remote git branch have the same contents.

Would it make sense for git to check for this possibility, and if the working tree file is the same as the file being merged in with that filename, allow the overwrite?

(I received the message with "git pull," so I imagine it was emitted by the recursive merge driver.)

-- Asheesh.
-- 
Reply hazy, ask again later.
Andreas Ericsson· Dec 1, 2008, 09:28 UTC · re: Asheesh Laroia · lore

Re: Overwriting untracked working tree files (when identical)

Asheesh Laroia wrote:
Show 11 quoted lines
> I was using git earlier today and got the familiar error:
> 
>     "Untracked working tree file 'filename’ would be overwritten by merge"
> 
> As it happens, I know that filename in my local filesystem and filename 
> in the remote git branch have the same contents.
> 
> Would it make sense for git to check for this possibility, and if the 
> working tree file is the same as the file being merged in with that 
> filename, allow the overwrite?
> 

That depends. git uses the work-tree to merge things. If one file is the same as that about to be written, it *might* make sense to clobber it, but what if it's identical to the expected merge-result? Git can't know that, but it's almost certainly a much saner approach than the other case, where the merge can go wahoonie-shaped at a later stage and thus require conflict resolution (which might well end up with the user getting fed up and doing "git reset --hard" to start over). For such cases, the file would appear to disappear, and that's a bad thing.

Overall, I think it's best if this is left as-is. The code would be too complex for the gain it provides.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

← back to recent threads