G.A.
G.A.

Reputation: 1523

GIT: Discrepancy when branching from a previous commit

I have a git tree as follows:

a -> b -> c-> d (develop)

Files:
b: f1, f2
c: f2, f2, f3
d: f1, f2, f3, f4

I made a branch out of previous commit (b). I did: git checkout -b test sha_of_b

a -> b -> c-> d (develop)
      \-> e (test)

When I use gitg to view the tree, it properly lists the files in my test branch as f1, f2. However, when I do ls in a terminal, I see f1,f2,f3 and f4 (I made sure I am checkout on test branch). Why this discrepancy? I was expecting ls to only show f1,f2.

I repeated this test in another folder (with simple files actually named as f1 f2 etc). But there I see results as expected.

Upvotes: 1

Views: 94

Answers (1)

Brian Campbell
Brian Campbell

Reputation: 332816

Have you modified the files? If you have local modifications to the files, then Git won't delete them when switching branches.

What does git status show you?

Upvotes: 3

Related Questions