Xcode:“工作副本 ____ 有未提交的更改”与 git 状态:“无需提交,工作目录干净”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20961822/
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
Xcode: "The working copy ____ has uncommitted changes" vs. git status: "nothing to commit, working directory clean"
提问by GarlicFries
In Xcode 5.0.2, I try to pull from a remote and am given the following message:
在 Xcode 5.0.2 中,我尝试从远程拉取并收到以下消息:
"The working copy 'project-name' has uncommitted changes. Commit or discard the changes and try again."
“工作副本‘项目名称’有未提交的更改。提交或放弃更改,然后重试。”
Fair enough. I pull up the commit dialog, and am then given the message, "This file does not exist at the requested revision." Clicking 'OK' brings me on into the commit dialog. (There is no revision displayed in the right pane, presumably for the same reason I was given the most recent message.) Selecting the flat view, I see that there is only one modified file: project.pbxproj
. I enter a commit message and click 'Commit 1 File'. When I then go to pull, I find that I am in exactly the same position as before--the same messages appear and I am unable to pull (or push) no matter how many times I make a commit.
很公平。我打开提交对话框,然后收到消息,“此文件在请求的修订版中不存在。” 单击“确定”使我进入提交对话框。(右窗格中没有显示修订,大概是因为我收到最新消息的原因。)选择平面视图,我看到只有一个修改过的文件:project.pbxproj
. 我输入提交消息并单击“提交 1 个文件”。然后当我去拉时,我发现我和以前的位置完全一样——出现相同的消息,无论我提交多少次,我都无法拉(或推)。
Curious, I run git diff
to see justwhat has changed. Nothing. git status
provides me with equally helpful output: nothing to commit, working directory clean
. git push
or git pull
? Yep, those work just fine from the command line.
出于好奇,我跑去git diff
看看发生了什么变化。没有。git status
为我提供了同样有用的输出:nothing to commit, working directory clean
. git push
或者git pull
?是的,这些在命令行中工作得很好。
So what gives? Why does Xcode insist that I have changes in my working directory? Why won't it tell me what they are? Have tried restarting Xcode and system. While I'm happy that I still have someway to push and pull, it would be really nice if the Xcode git integration was behaving nicely. Any ideas?
那么什么给呢?为什么 Xcode 坚持我的工作目录有更改?为什么它不告诉我它们是什么?已尝试重新启动 Xcode 和系统。虽然我很高兴我仍然有一些推和拉的方法,但如果 Xcode git 集成表现良好,那就太好了。有任何想法吗?
I've found these similar questions, but none address this particular issue (or provide an acceptable solution):
我发现了这些类似的问题,但没有一个解决这个特定问题(或提供可接受的解决方案):
- Cannot push, pull or merge git. "Working copy has uncommited changes"
- Commit or discard the changes and try again
- Git pull fails: You have unstaged changes. Git status: nothing to commit (working directory clean)
- Xcode Version Controll GIT - has uncommitted changes, just after commit
- Xcode says "Uncommitted Changes" Whenever I try to git pull or push
回答by Robert J. Clegg
Okay, so I fixed my issue.
好的,所以我解决了我的问题。
With Xcode open:
打开 Xcode:
- Open terminal - cd / to your project directory.
- Type in: "
git reset --hard
" - Type in
git status
- 打开终端 - cd / 到您的项目目录。
- 输入:“
git reset --hard
” - 输入
git status
Restart Xcode and make a commit (Just a comment or something )
重新启动 Xcode 并进行提交(只是评论或其他内容)
Repeat the above steps.
重复以上步骤。
This sorted out my issue for me.
这为我解决了我的问题。
回答by Matt H
You must fix it with command line git. Go to your working folder in Terminal, type:
您必须使用命令行 git 修复它。转到终端中的工作文件夹,键入:
git status
That will show you what files have uncommitted changes. Crashlytics, for instance, will update itself as soon as you run it, and even using Xcode/Source Control/Discard Changes won't get rid of it.
这将显示哪些文件具有未提交的更改。例如,一旦您运行 Crashlytics,它就会自动更新,即使使用 Xcode/Source Control/Discard Changes 也无法摆脱它。
Once you see the files that have uncommitted changes (ignore added files), use:
一旦您看到具有未提交更改的文件(忽略添加的文件),请使用:
git checkout -- Folder/filename.ext
That's the same as a "discard" in Xcode.
这与 Xcode 中的“丢弃”相同。
After you've done that, go back to Xcode and you should be able to switch branches.
完成后,返回 Xcode,您应该能够切换分支。
回答by Tr0yJ
App Code solution:
应用代码解决方案:
Confirm git status in Terminal:
git status
Open 'yourProject.xcworkspace' in App Code
VCS > Git > Branches...
Remote Branches > yourBranch > Checkout as new local branch
Confirm fix via Terminal:
git status
在终端中确认 git 状态:
状态
在应用程序代码中打开“yourProject.xcworkspace”
VCS > Git > 分支...
远程分支 > yourBranch > Checkout 作为新的本地分支
通过终端确认修复:
状态
回答by J. Doe
xCode is really-really crappy. Everytime you just look at files, a file called UserInterfaceState.xcuserstate is changed. You don't see it in the overview of xCode itself, through the command line you can.
xCode 真的非常糟糕。每次只查看文件时,都会更改名为 UserInterfaceState.xcuserstate 的文件。您在 xCode 本身的概述中看不到它,通过命令行可以。
Quick fix:
快速解决:
- Open Terminal
- CD to your project directory, and type the following:
git add .
git commit -m "Commit"
git push origin master
- 打开终端
- CD 到您的项目目录,然后键入以下内容:
git add .
git commit -m "Commit"
git push origin master