代码之家  ›  专栏  ›  技术社区  ›  Kevin Reid

为什么git checkout会为一些未更改的文件打印“M”?

git
  •  0
  • Kevin Reid  · 技术社区  · 7 年前

    事情就这样发生了:

    $ git branch
    * master
    ...lots of other branches...
    
    $ git checkout -tb feat/bandwidthprelude
    M   MANIFEST.in
    M   lint.sh
    M   setup.py
    M   ...some other source files...
    Branch 'feat/bandwidthprelude' set up to track local branch 'master'.
    Switched to a new branch 'feat/bandwidthprelude'
    
    $ git status
    On branch feat/bandwidthprelude
    Your branch is up to date with 'master'.
    
    Untracked files:
      (use "git add <file>..." to include in what will be committed)
    
        ...[redacted]...
    
    nothing added to commit but untracked files present (use "git add" to track)
    

    git checkout 切换分支时,将打印 M 当文件有本地修改时。但在这种情况下,根据 git status 这些文件没有本地修改 ,尽管它们是我最近编辑和提交的文件)。我确认我最后的编辑没有丢失。 怎么搞的?

    git checkout -tb <branchname>

    1 回复  |  直到 7 年前
        1
  •  3
  •   Kevin Reid    7 年前

    看起来这是由文件元数据更改触发的误报(修改是真实的,但不是Git跟踪的信息)。

    git checkout -b A. git checkout M 线

    如果我只是 touch 以前的文件 git签出-b

    所以,只是一个小虫子,基本上是无害的。