Thread (4 messages) flat view 4 messages, 2 authors, 2016-06-15

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

From: Stian Haklev <hidden>
Date: 2016-06-15 22:43:11

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help