我是git的新手。因此,我很困惑,可能没有使用正确的术语。
我有两个单独的Xcode项目,每个项目都有自己的本地存储库。尽管项目具有相似的名称,但是每个项目都有单独且不同的源文件。我已经对每个对象执行了两次提交,但是当我在一个项目中提交时,该提交同时显示在两个项目中。我的新项目在git导航器中显示了两个项目(这可能与问题有关)。当我进行新提交时,旧项目未在Xcode中打开。
每个项目都有自己的.git文件夹。
细节:
旧项目1(“计划程序”):显示一个存储库,但是我在新项目中所做的最后一次提交显示在其中。
新项目2(“ Scheduler6”):显示两个存储库,而我在其中所做的最后一个提交在两个存储库中都显示。
为什么Project 2会同时显示两个存储库,这是我的提交最终出现在两个存储库中的原因?如何纠正呢?这以前发生过,我在旧存储库中进行了“ git reset HEAD ^”操作,以删除错误的提交。我想永远停止这种行为。(而且我对在终端中混入git命令犹豫不决。)
Mystery solved. I created Project 2 by copying numerous files from Project 1, but three image files ended up as references to the Project 1 files, not copies. When I removed those references and added copies instead to Project 2, the GIT navigator stopped showing the Project 1 repository.
Summary: Project 2 showed both GITs because Project 2 referenced some files in Project 1.
There are two ways to fix the trouble:
A. Manually: Open Project 2, select each file (one by one), and check that the Full Path shown in the Identity and Type inspector is a Project 2 path. Fix any files that reference Project 1.
B. Using Terminal: The Xcode project control file is a text file, so checking all Full Paths can be automated using Terminal commands, thusly:
(I assume the two projects are named Project_1 and Project_2, and that their project folders share the same parent folder.)
Duplicate Project_2.xcodeproj
(which is actually a bundle).
Change the duplicate's filename suffix from .xcodeproj
(I used .xxx
). The duplicated "file" becomes a subfolder containing four items, one of which is a text file ("project.pbxproj
").
Launch Terminal.
In Terminal, execute "cd path_to_project_2_subfolder
". Shortcut: type 'cd
', space, drag the folder that as created in step 2 to Terminal, and hit return.
x. (Verification step.) In Terminal, execute "ls
" to show the four items. They should be:
project.pbxproj project.xcworkspace/ xcshareddata/ xcuserdata/
strings project.pbxproj | grep ../Project_1/
". This shows all lines in project.pbxproj that reference Project_1. '|
' is a pipe command that sends the strings
output to grep
which filters the strings. Because my two project names differed by only one character, I surrounded the project name with '../
' and '/
' to limit the output to directories and files that belong to Project_1, but you could just use the bare project name if your two names are dis-similar. The commands and arguments are case-sensitive. You should see some lines that reference Project_1. You could also open project.pbxproj
in a text editor and search for lines containing Project_1
.One of my files (sharing.png) appeared thusly:
1F4E32C32343DE1A0053C239 / * Sharing.png * / = {isa = PBXFileReference; lastKnownFileType = image.png; 名称= Sharing.png; 路径= ../../../../Project_1/sharing.png; sourceTree =“”; };
在Xcode中打开Project_2并修复在strings命令中显示为引用的文件。在此过程中,使用方法A(上述)验证您的工作。
检查GIT导航器仅显示Project2。您可能必须关闭Xcode并重新启动。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句