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

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

From
APAndy Parkins <andyparkins@gmail.com>
Date
May 21, 2007, 09:16 UTC
Message-ID
<200705211016.58067.andyparkins@gmail.com>
In-Reply-To
<566574ef0705210159m69d4e32cjd4bc5db66c1677b1@mail.gmail.com>
On Monday 2007 May 21, Stian Haklev wrote:
What does "git --version" say?
Show 10 quoted lines
> ~wiki/> git checkout trying-new-feature
> checked out
> ~wiki/> git status
> no files updated
> ~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.

Something has gone very wrong here. You are right to be confused, that is not what one would expect from git. After a git-checkout you should expect that the index is clean.

Did you get any error messages during any of those operations?
Are you sure you aren't doing something like
  git checkout trying-new-feature -- list of files
As that would update the working tree but not the current HEAD, and would 
therefore appear as changes to master.

When you do the final git-status, are the files being listed in the "Changed but not updated" section or the "Changes to be committed" section?

Can you make a minimal test case? e.g.
 mkdir testing-git; cd testing-git
 git init
 date > file1
 git add file1
 git commit -a -m "step1"
 date >> file1
 git commit -a -m "step2"
 git checkout -b newbranch HEAD^
 date >> file1
 git commit -a -m "step3"
 git checkout master
 git checkout newbranch
 git status
Andy
-- 
Dr Andy Parkins, M Eng (hons), MIET
andyparkins@gmail.com
Previous: Stian HaklevNext: Stian Haklev
Message 2 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.