简体   繁体   English

GIT:从先前提交分支时出现差异

[英]GIT: Discrepancy when branching from a previous commit

I have a git tree as follows: 我有一个如下的git树:

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). 我在之前的提交(b)中做了一个分支。 I did: git checkout -b test sha_of_b 我做了: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 . 当我使用gitg查看树时,它正确地将我的测试分支中的文件列为f1f2 However, when I do ls in a terminal, I see f1 , f2 , f3 and f4 (I made sure I am checkout on test branch). 但是,当我在终端中执行ls时,我会看到f1f2f3f4 (我确定我在测试分支上结帐)。 Why this discrepancy? 为什么会出现这种差异? I was expecting ls to only show f1 , f2 . 我期待ls只显示f1f2

I repeated this test in another folder (with simple files actually named as f1 f2 etc). 我在另一个文件夹中重复了这个测试(简单文件实际上命名为f1 f2等)。 But there I see results as expected. 但在那里我看到了预期的结果。

Have you modified the files? 你修改过文件了吗? If you have local modifications to the files, then Git won't delete them when switching branches. 如果您对文件进行了本地修改,那么Git在切换分支时不会删除它们。

What does git status show you? git status告诉你什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM