且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Xcode 8:如何将GIT存储库添加到现有项目

更新时间:2023-02-16 22:53:37

检查您是否在您的源代码管理中启用了现有的XCode项目。

Xcode>偏好...>源代码管理:检查启用源代码管理框。

这会让您访问Git菜单命令。



有关完整教程(仅限XCode,而不是git命令行),请参阅



OP RobertL 增加在评论中


这个答案错过了一件事,即它只将一个文件放入存储库,而不是所有的项目文件。 >
如果您对每个文件进行更改e项目并再次提交,他们都进入存储库。



When I created this Xcode (Swift) project I forgot to check "Create Git repository". I spent many hours getting the first part of the project working and then realized I can't do a GIT commit. Is there some way to correct that oversight? IOW is there a way to change an existing Xcode project to include a GIT repository?

Usually I make a GIT commit right at the beginning but I obviously forgot to do that.

I'm not going to spend the time to learn GIT command line commands. If that's what it would take I'll instead make a new project that includes a repository and copy everything into it from the existing project. I've done that before but it's not quite as simple as it sounds.

Check if you have enabled Source Control in your existing XCode project.

Xcode > Preferences... > Source Control: check the Enable Source Control box.
That will give you access to Git menu commands.

For a full tutorial (XCode only, not git command line), see "Using Git with an existing XCode project" (answer starting with "Xcode 7 (and 8)")

The OP RobertL adds in the comments:

that answer misses one thing, namely that it puts only one file into the repository, not all of the project files.
If you make a change in every file in the project and commit again they all get into the repository.