xcode 无法将更改提交到本地 git 存储库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8148544/
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-14 22:26:56  来源:igfitidea点击:

Can't commit changes to local git repository

xcodegit

提问by JAHelia

I have created a new project and checked the "create a local git repository" option. I opened the organizer to check that there is a repository for my project and it was there. I made some changes on some files, and noticed the source control specific letters "A" .. "M" beside them, but when I choose: File-> Source Control -> Commit, I get the following message from XCode 4.2:

我创建了一个新项目并选中了“创建本地 git 存储库”选项。我打开了管理器来检查我的项目是否有一个存储库,并且它就在那里。我对某些文件进行了一些更改,并注意到它们旁边的源代码管理特定字母“A”..“M”,但是当我选择:文件-> 源代码管理-> 提交时,我从 XCode 4.2 收到以下消息:

the operation could not be performed because no valid working copies were found

the operation could not be performed because no valid working copies were found

Please verify that your files are under source control and try again

Please verify that your files are under source control and try again

However, I opened the organizer again, and noticed that the repository of my project includes three icons on the left bar: Branches, Remotes and a folder with the same name as of the project. I chose the last one (the folder) and pressed the Commit button on the bottom bar of the organizer. The commit sheet opened and I performed the commit successfully. Now, when I close the organizer, and edit some files in my project, I do not see the source control specific letters "M" ... "A" ... beside each modified file.

但是,我再次打开管理器,发现我的项目的存储库在左侧栏上包含三个图标:Branches、Remotes 和一个与项目同名的文件夹。我选择了最后一个(文件夹)并按下了组织者底部栏上的提交按钮。提交表打开,我成功执行了提交。现在,当我关闭管理器并编辑项目中的某些文件时,我在每个修改后的文件旁边都看不到源代码管理特定的字母“M”...“A”...。

My problem is about two points:

我的问题是关于两点:

1) Why can't I commit from File->Source Control->Commit menu option

1) 为什么我不能从 File->Source Control->Commit 菜单选项提交

2) When I commit from the repository itself, and go back to the project and edit some files, why do not I see source control letters beside modified files?]

2)当我从存储库本身提交,并返回项目并编辑一些文件时,为什么我在修改的文件旁边看不到源代码控制字母?]

回答by brainjam

For what it's worth (and as @Jahelia's comment mentions), this seems to be a bug in XCode 4.2 when it first engages with git. The workaround seems to be to at least close Xcode and reopen. (If that doesn't work, try opening and closing the organizer.)

就其价值而言(正如@Jahelia 的评论所提到的),这似乎是 XCode 4.2 首次使用 git 时的一个错误。解决方法似乎是至少关闭 Xcode 并重新打开。(如果这不起作用,请尝试打开和关闭组织器。)

I encountered this myself today when trying out Git with Xcode for the first time. I created two demo projects with the "create a local git repository" option and they had the same problem. I was able to commit from the organizer window, but the main Xcode file view didn't seem to recognize git at all.

我今天在第一次用 Xcode 尝试 Git 时遇到了这个问题。我使用“创建本地 git 存储库”选项创建了两个演示项目,它们遇到了同样的问题。我能够从组织者窗口提交,但主 Xcode 文件视图似乎根本无法识别 git。

After quitting and restarting, I created a third demo with the git option, and the main window recognized the changes (after building) right off the bat - i.e showed the "M" beside a modified file.

退出并重新启动后,我使用 git 选项创建了第三个演示,主窗口立即识别了更改(构建后) - 即在修改后的文件旁边显示“M”。

回答by user19666

I've experienced and recovered from this.

我经历过并从中恢复过来。

I can't tell you what causes it but, notably, in the "Repositories" view in my Organiser, I had TWO similarly-named repositories. What differed about them was the case of one of the paths.

我不能告诉你是什么导致了它,但值得注意的是,在我的组织者的“存储库”视图中,我有两个同名的存储库。它们的不同之处在于其中一条路径的情况。

One was "~/Work/Code/Bumhole" and the other "~/work/Code/Bumhole".

一个是“~/Work/Code/Bumhole”,另一个是“~/work/Code/Bumhole”。

I causedthe problem by XCode crashing during a commit to the repository (of manychanges).

我在提交到存储库(许多更改)期间 XCode 崩溃导致了这个问题。

I fixedthe problem by

解决了这个问题

  • closing the offending project
  • closing Xcode
  • rebooting
  • reopening Xcode
  • (close the project if its open)
  • open the Organiser view
  • Select the "bad" repository and delete it with backspace
  • Navigate the remaining "good" repository until you see the .xcodeproj file
  • Double click the .xcodeproj file to open the project
  • 关闭违规项目
  • 关闭 Xcode
  • 重启
  • 重新打开Xcode
  • (如果项目打开则关闭项目)
  • 打开管理器视图
  • 选择“坏”存储库并使用退格键将其删除
  • 导航剩余的“好”存储库,直到看到 .xcodeproj 文件
  • 双击 .xcodeproj 文件打开项目

I expect this list is a superset of the steps needed to fix the problem, but this worked for me.

我希望这个列表是解决问题所需步骤的超集,但这对我有用。

回答by JeffK

This bug still exists in Xcode 4.6.3 and when using Subversion.

这个错误在 Xcode 4.6.3 和使用 Subversion 时仍然存在。

回答by Dylanthepiguy

I know this has already been answered but this worked for me:

我知道这已经得到了回答,但这对我有用:

Open terminal

打开终端

cd yourprojectdirectory
git config --global user.email "[email protected]"
git config --global user.name "username"

回答by januszb

If your project is in /Developer/.... move it elsewhere and reopen the project. This may resolve your problem.

如果您的项目在 /Developer/.... 将它移到别处并重新打开项目。这可能会解决您的问题。

There seems to be a problem under Xcode 4.2 with projects in /Developer/... and git integration (you get the error "The operation could not be performed because no valid working copies were found. Please verify that your files are under source control and try again")

Xcode 4.2 下的项目似乎存在问题 /Developer/... 和 git 集成(您收到错误“无法执行操作,因为找不到有效的工作副本。请验证您的文件是否受源代码控制然后再试一次")