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

Fwd: Problem: git doesn't update working dir (always) when checkout'ing other branch

From
Stian Haklev <shaklev@gmail.com>
Date
May 21, 2007, 08:59 UTC
Message-ID
<566574ef0705210159m69d4e32cjd4bc5db66c1677b1@mail.gmail.com>
In-Reply-To
<566574ef0705210157j14cb7c56h62392c6193472a98@mail.gmail.com>

Newbie to git, but I've been reading up on the docs and I really love both the theory and what it let's you do (still confused by some issues like rebasing and stuff). For now I mostly use it on my own small projects (where I frequently make branches, merge, cherry-pick etc), and also push it to repo.or.cz.

One confusing thing to me is that if I am in a clean state (no updated files in working dir), and I checkout another branch (or another treeish), sometimes git doesn't update the working dir, and sometimes it does. So for example in my own repo I do

~wiki/> git status no files updated

~wiki/> git checkout trying-new-feature checked out

~wiki/> git status no files updated

(this is how it should be obviously - the working dir reflects the index which is now pointing at trying-new-feature, but then...)

~wiki/> git checkout master checked out

~wiki/> git status it then puts me directly into commit mode, with every file having a ton of differences - because the files are still from trying-new-feature and the index is pointing at master.

It also seems to do inconsistent things with files that exist in only one of the branches - ie if switching back the file remains in the directory but is now an "untracked" file, etc.

Maybe I am completely misunderstanding and there is something I should do differently. It works out if I do git reset --hard, but it just seems so uneccessary. (As I said, in all cases the working dir is completely clean before doing the checkout).

thank you Stian

Next: Andy Parkins
Message 1 of 4 in “Fwd: Problem: git doesn't update working dir (always) when checkout'ing other branch”
  1. Stian HaklevMay 21, 2007
  2. Andy ParkinsMay 21, 2007
  3. Stian HaklevMay 22, 2007
  4. Andy ParkinsMay 22, 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.