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

checkout and rm

From
JJJeff Jenkins <jeff@shopwiki.com>
Date
Sep 7, 2007, 02:59 UTC
Message-ID
<4F2CF06E-CCC6-4597-A1BF-663BC36B9A94@ShopWiki.com>

I couldn't find a thread in the archive about this. Here's the abbreviated scenario:

$ git add bar.c $ git-rm foo.c rm 'foo.c' $ git-status # On branch FOO # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: bar.c # deleted: foo.c #

$ git-checkout master M bar.c Switched to branch "master" $ git-status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: bar.c #

When I change branches:
- the modified files in the index/working directory stay there  
(that's fine)
- the *removed* files are re-added to the working directory when the  
branch changes
- the remove entries aren't in the index anymore

There was no warning about any the lost changes, and if the intent was to commit these changes to master because you were in FOO by accident, then only some would be committed if you weren't paying close attention. If working directory/index changes are going to be kept when a branch switch is done, then the remove changes should be propagated as well.

Ideally there would be a config setting which would stop checkouts if the working directory or index were dirty (and a flag on checkout which overrode the setting). With stash in 1.5.3 the only reason I can think of to allow working directory changes to propagate is gone (though i haven't tested how stash works with rm'd files). At the very least, there should be a warning and a prompt if some of the changes are going to vanish by a user action

-Jeff Jenkins
Next: Junio C Hamano
Message 1 of 2 in “checkout and rm”
  1. Jeff JenkinsSep 7, 2007
  2. Junio C HamanoSep 7, 2007

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.