【问题标题】:Commit or discard the changes and try again提交或放弃更改并重试
【发布时间】:2013-04-15 08:58:36
【问题描述】:

我想将源代码推送到遥控器时遇到问题。但是 xcuserstate 文件总是被更改,并且 Git 宣布“提交或放弃更改并重试”。所以我试图忽略 xcuserstate 文件,但我不能

怎么解决???

【问题讨论】:

  • 你能给我们看看git status的输出吗?

标签: xcode git version-control ignore


【解决方案1】:

错误消息非常具体地说明了你应该做什么:要么提交文件(如果你想保留更改)或丢弃它(如果你不关心变化)。

cuser 文件通常隐藏在 xcode 项目的深处,因此您可能需要提供它们的完整路径(以下示例使用 find 在子目录中查找这些文件)

提交

这将提交您当前目录中的所有个 cuser 文件:

$ git add $(find . -name "*.xcuserstate" -or -name "*.xcuserdata")
$ git commit $(find . -name "*.xcuserstate" -or -name "*.xcuserdata") -m "updated xcuser stuff"

丢弃

这将丢弃当前目录中 所有 cuser-files 的更改:

$ git checkout $(find . -name "*.xcuserstate" -or -name "*.xcuserdata")

通常您根本不想跟踪 xcuser-stuff,因此您应该将其从存储库中删除并确保它不会被意外添加:

# remove cuser-stuff from the repository (but not locally)
$ git rm --cached $(find . -name "*.xcuserstate" -or -name "*.xcuserdata")
# commit the file removal
$ git commit $(find . -name "*.xcuserstate" -or -name "*.xcuserdata") -m "don't track cuser stuff"
# prevent the cuser-stuff from accidentally adding it
$ echo "*.cuserdata" > .gitignore
$ echo "*.cuserstate" > .gitignore
$ git add .gitignore
$ git commit .gitignore -m "don't track user-specific data"

【讨论】:

    猜你喜欢
    • 2015-01-11
    • 2011-02-15
    • 2013-01-12
    • 2021-04-12
    • 2017-06-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多