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

Re: checkout on an empty directory fails

From
DSDirk Süsserott <newsletter@dirk.my1.cc>
Date
Jan 5, 2012, 19:33 UTC
Message-ID
<4F05FB05.3090706@dirk.my1.cc>
In-Reply-To
<4F05ACD6.6040603@ira.uka.de>
Am 05.01.2012 14:59 schrieb Holger Hellmuth:
Show 37 quoted lines
> On 05.01.2012 13:38, René Doß wrote:
>> git status says not special informations.
> 
>  versus
> 
>> red@linux-nrd1:~/iso/a> git status
>> # On branch master
>> # Changed but not updated:
>> # (use "git add/rm <file>..." to update what will be committed)
>> # (use "git checkout -- <file>..." to discard changes in working
>> directory)
>> #
>> # deleted: SP601_RevC_annotated_master_ucf_8-28-09.ucf
>> # deleted: rtl/ether_speed.vhd
>> # deleted: rtl/ether_top.vhd
>> # deleted: rtl/ether_tx.vhd
>> # deleted: rtl/takt.vhd
>> # deleted: sim/makefile
>> # deleted: sim/tb_ether_top.vhd
>> #
> 
> This *is* special information: It tells you that master has those 7
> files but your working directory has none of them (i.e. it is as if you
> had deleted them from your working directory).
> 
> "git checkout <branch>" switches between branches, *but* leaves changes
> you made (files you edited, added or deleted) intact! This is so you can
> switch branches before commiting if you suddenly realize you are in the
> wrong branch.
> 
> "git checkout -- <paths...>" or in your case "git checkout -- ." is
> different, it really overwrites the files in your working dir with the
> versions stored somewhere else, by default from the index.
> 
>> What means the point in checkout?
> 
> "." is simply your current directory
Another way of reviving the deleted files and restore the master branch is
$ git checkout -f master # or git checkout --force master

This will unconditionally checkout master and overwrite the local changes, including the deletions Holger mentioned.

For me, "checkout --force" is more intuitive than "reset --hard" or "checkout .".

    Dirk
Previous: Holger HellmuthNext: Ramkumar Ramachandra
Message 5 of 7 in “checkout on an empty directory fails”
  1. René DoßJan 5, 2012
  2. Nguyen Thai Ngoc DuyJan 5, 2012
  3. René DoßJan 5, 2012
  4. Holger HellmuthJan 5, 2012
  5. Dirk SüsserottJan 5, 2012
  6. Ramkumar RamachandraJan 5, 2012
  7. Thomas RastJan 5, 2012

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.