xcode 无法推送、拉取或合并 git。“工作副本有未提交的更改”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11910228/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 01:12:21  来源:igfitidea点击:

Cannot push, pull or merge git. "Working copy has uncommited changes"

iosxcodegitrepositorybitbucket

提问by Neil

I have recently set up a git repository on bitbucket, and have added an old project onto it. I have committed and pushed a change as a test, but now I face this problem.

我最近在 bitbucket 上建立了一个 git 存储库,并在其中添加了一个旧项目。我已经提交并推动了一个更改作为测试,但现在我面临这个问题。

Each time I try to Pull, Push, or Merge I get this error message:

每次我尝试拉、推或合并时,都会收到以下错误消息:

The working copy "" has uncommitted changes.

工作副本“”有未提交的更改。

"The working copy 'Project_Name' has uncommitted changes".

“工作副本‘Project_Name’有未提交的更改”。

And I have committed this change several times:

我已经多次提交此更改:

The file seems to be named: User Interface State

该文件似乎被命名为:用户界面状态



EDIT: I did 'git status' and got the following:

编辑:我做了 'git status' 并得到以下内容:

# On branch master
# Your branch is ahead of 'origin/master' by 2 commits.
#
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   Crunch.xcodeproj/project.xcworkspace/xcuserdata/Neil.xcuserdatad/UserInterfaceState.xcuserstate
#
no changes added to commit (use "git add" and/or "git commit -a")


Help would be greatly appreciated, SirKaydian

将不胜感激,SirKaydian

回答by Gangcil

Step 1:

第1步:

git rm --cached ProjectName.xcodeproj/project.xcworkspace/xcuserdata/username.xcuserdatad/UserInterfaceState.xcuserstate

Step 2:

第2步:

git commit -m "Removed file that shouldn't be tracked"

回答by Neil

Okay, turns out I just had to make a comment

好吧,原来我只需要发表评论

//THIS IS A TEST

And commit that. Now it works fine. This must have just been some strange bug.

并承诺。现在它工作正常。这一定只是一些奇怪的错误。

Thanks for the help though, SirKaydian

感谢您的帮助,SirKaydian

回答by robrich

I'm unfamiliar with the .xcuserstatefile, but it sounds like a user-specific file. Generally user-specific files have no business in source control. They change frequently, generally are binary and thus difficult to diff, and aren't helpful to other users. Try closing down your IDE then running the commands or try adding this file name to your .gitignorefile.

我不熟悉该.xcuserstate文件,但听起来像是用户特定的文件。通常,特定于用户的文件在源代码管理中没有任何作用。它们经常更改,通常是二进制的,因此难以区分,并且对其他用户没有帮助。尝试关闭您的 IDE,然后运行命令或尝试将此文件名添加到您的.gitignore文件中。

回答by haiwuxing

I solved this problem by:

我通过以下方式解决了这个问题:

git push <remote> localbranch --force.

Do not use the --force flag unless you're absolutely sure you know what you're doing.

不要使用 --force 标志,除非您绝对确定自己知道自己在做什么。

回答by MobileMon

git rm --cached *.xcuserstate *.xcuserdata

Run the above command. Then commit, then push.

运行上面的命令。然后提交,然后推送。

See here: Xcode says "Uncommitted Changes" Whenever I try to git pull or push

请参阅此处:每当我尝试 git pull 或 push 时,Xcode 都会说“未提交的更改”

You may need to run them separately :

您可能需要单独运行它们:

git rm --cached *.xcuserstate
git rm --cached *.xcuserdata