git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: pulling the root commit overwrites untracked files without warning (1.7.2.3)

From
Clemens Buchacher <drizzd@aon.at>
Date
Nov 14, 2010, 21:34 UTC
Message-ID
<20101114213453.GA29287@localhost>
In-Reply-To
<AANLkTimDnyzyV1FEEwEuxLfG1nSOcNa7Hzwt7DDssjba@mail.gmail.com>
Hi,
On Thu, Oct 21, 2010 at 04:18:19PM +0300, Gert Palok wrote:
Show 21 quoted lines
> 
> On 1.7.2.3, pulling the root commit overwrites untracked files
>
> Minimal working example:                                                        
> $ git init wc1                                                                  
> $ cd wc1                                                                        
> $ echo a > a                                                                    
> $ git add a                                                                     
> $ git commit -m "added a"                                                       
> $ mkdir ../wc2                                                                  
> $ cd ../wc2                                                                     
> $ echo b > a                                                                    
> $ git init                                                                      
> $ git remote add origin ../wc1                                                  
> $ git pull origin master                                                        
> $ # expected: error: Untracked working tree file 'a' would be                   
> overwritten by merge.  Aborting                                                 
> $ # actual: no error                                                            
> $ cat a                                                                         
> $ # expected: b                                                                 
> $ # actual: a

I finally got a chance to look at this. Contrary to my initial suspicion, it's not a problem with the merge algorithm at all. It doesn't even do a merge.

Instead, git merge finds that it has no valid HEAD and therefore does a hard reset, which obviously overwrites any files already there.

Patch to follow.
Clemens
Previous: Clemens BuchacherNext: Clemens Buchacher
Message 4 of 9 in “pulling the root commit overwrites untracked files without warning (1.7.2.3)”
  1. Gert PalokOct 21, 2010
  2. Clemens BuchacherOct 22, 2010
  3. Clemens BuchacherOct 22, 2010
  4. Clemens BuchacherNov 14, 2010
  5. do not overwrite untracked during merge from unborn branchClemens Buchacher, Nov 14, 2010
  6. do not overwrite untracked during merge from unborn branchClemens Buchacher, Nov 14, 2010
  7. do not overwrite untracked during merge from unborn branchClemens Buchacher, Nov 14, 2010
  8. Miles BaderNov 15, 2010
  9. do not overwrite untracked during merge from unborn branchClemens Buchacher, Nov 14, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.