【问题标题】:git still untracked after add添加后git仍然未跟踪
【发布时间】:2011-03-27 16:35:46
【问题描述】:

每次我执行 git status 时,都会有这个文件夹显示为未跟踪。

$ git status
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       src/error/
nothing added to commit but untracked files present (use "git add" to track)

即使在执行git add .、git commit -a 之后,src/error 处的文件夹仍然显示为未跟踪。每次只有这个文件夹不断出现问题时,其他未暂存的文件都会被提交。 git也不会报告任何错误。这可能是什么问题?

【问题讨论】:

  • 你试过git add src/error/吗?
  • 我试过它没有用我在那个文件夹中有一个文件我也尝试直接添加那个文件也没有用。
  • 您是否尝试在 src/error 下添加特定文件?你的 .gitignore 文件中有什么?
  • 你能告诉我们你运行的命令和它的输出吗?您的 .gitignore 文件的内容也会有所帮助。最佳猜测:尝试在 git add 中使用“-f”标志。
  • 对于这个项目,我没有使用 exclude 或 .gitignore 文件。我跑了 $ git add 。 -f -v 我没有得到任何输出。然后我做了 git status ,我得到了与第一条消息相同的输出,告诉我该文件夹未跟踪。

标签: git version-control commit add


【解决方案1】:

我发现了问题和解决方案,这就是发生的事情:

当我在本地更改案例时,第一个 src/error 被称为 src/Error,文件夹名称已更改,但在 git 中它仍被提交为 src/Error。 Windows 不区分大小写,所以我所做的是删除文件夹提交并使用正确的大小写再次添加它。

【讨论】:

  • 谢谢,这对我有帮助!
【解决方案2】:

如果是文件夹为空是否正常,见here

【讨论】:

    【解决方案3】:

    我在 Windows 7 控制台中尝试了以下操作,并且成功了,即它没有将 \src\error\ 显示为未跟踪。

    C:\t>dir
     Volume in drive C is BLAH
     Volume Serial Number is 2ECA-CB88
    
     Directory of C:\t
    
    10.08.2010  17:56    <DIR>          .
    10.08.2010  17:56    <DIR>          ..
                   0 File(s)              0 bytes
                   2 Dir(s)  59'844'902'912 bytes free
    
    C:\t>mkdir .\src\error
    
    C:\t>copy con: .\src\error\text.txt
    blah^Z
            1 file(s) copied.
    
    C:\t>git init
    Initialized empty Git repository in C:/t/.git/
    
    C:\t>git add .\src\error\*
    
    C:\t>git status
    # On branch master
    #
    # Initial commit
    #
    # Changes to be committed:
    #   (use "git rm --cached <file>..." to unstage)
    #
    #       new file:   src/error/text.txt
    #
    

    这不能回答您的问题,但我认为查看完整的分步示例可能会有所帮助。

    【讨论】:

      猜你喜欢
      • 2017-12-30
      • 2021-02-24
      • 1970-01-01
      • 2016-02-07
      • 1970-01-01
      • 2012-04-02
      • 1970-01-01
      • 1970-01-01
      • 2016-02-20
      相关资源
      最近更新 更多