【问题标题】:Duplicates of a .swift file are shown in terminal from git when running the command git status运行命令 git status 时,.swift 文件的副本会显示在 git 的终端中
【发布时间】:2017-04-08 08:16:34
【问题描述】:

我在我的项目中进行了一些更改,并在终端中使用 git status 命令检查了状态,以便在验证我更改的所有文件后提交更改。更改的文件都很好,但是它显示了一个文件的一些重复项。假设文件的名称是 xyz.swift。它显示如下输出:

On branch MyBranch
Untracked files:
  (use "git add <file>..." to include in what will be committed)

root/Subroot/Core/xyz.swift 10.swift
root/Subroot/Core/xyz.swift 11.swift
root/Subroot/Core/xyz.swift 12.swift
root/Subroot/Core/xyz.swift 13.swift
root/Subroot/Core/xyz.swift 14.swift
root/Subroot/Core/xyz.swift 15.swift
root/Subroot/Core/xyz.swift 16.swift
root/Subroot/Core/xyz.swift 17.swift
root/Subroot/Core/xyz.swift 5.swift
root/Subroot/Core/xyz.swift 6.swift
root/Subroot/Core/xyz.swift 7.swift
root/Subroot/Core/xyz.swift 8.swift
root/Subroot/Core/xyz.swift 9.swift

nothing added to commit but untracked files present (use "git add" to track)

有人可以帮我解决这个问题吗?这种重复的数量不断增加。首先是 4 或 5 个文件。现在它显示了超过 25 个这样的文件。如果我使用 git add -u 这些文件不会被添加。但如果我做 git add .,它会创建重复项并添加到项目中。此外,在我的 XCode 项目中,只有一个 xyz.swift 是可见的。但是,不知何故,在终端中,它显示了这些奇怪的重复项。

非常感谢您的帮助。

提前致谢....祝您编码愉快。

【问题讨论】:

  • 您是否从某个地方复制了文件?在 mac 中,当您复制文件时,如果文件名相同,您最终会出现重复。 Xcode 在将其添加到项目之前不会识别它们。
  • 没有@GoodSp33d,我已经从远程存储库克隆了项目。

标签: xcode git terminal


【解决方案1】:

在 Xcode 中查看您的目标的构建阶段,了解是否存在“复制文件”构建阶段。

它可能看起来像这样:

我的猜测是 Xcode 一次又一次地将 Swift 文件复制到同一个地方,而不是删除以前的文件,Xcode 有助于添加另一个副本。无论哪种方式,请确保您没有不应该存在的 Copy Files 构建阶段。

【讨论】:

    猜你喜欢
    • 2013-01-11
    • 2013-04-01
    • 2020-12-09
    • 2014-04-19
    • 1970-01-01
    • 2015-12-04
    • 1970-01-01
    • 2018-11-20
    • 1970-01-01
    相关资源
    最近更新 更多