简体   繁体   English

Git本地存储库管理

[英]Git local repository management

I am quite new to git but the advantages to use it are quite clear! 我对git很陌生,但是使用它的好处非常明显! I have been developing for iOS and I have created some custom class of mine that I share among several projects, I would like to keep them centralized so I can pull and push only from/in a single place, and only that specific folder will be always up to date with the latest changes, that can come from different projects. 我一直在为iOS开发,并创建了我的自定义类,我在多个项目中共享该类,我希望将它们集中化,这样我就只能从一个地方拉/推,并且只有该特定文件夹才是始终保持最新状态,这些变化可能来自不同的项目。

How can I setup practically a scenario like this? 我实际上如何设置这样的场景? I really thank you in advance! 我真的非常感谢你!

You can think about a git repository in one of 2 ways: 您可以通过以下两种方式之一来考虑git存储库:

If you think of it as a git owned / controlled repository then you might want to add other repositories to it. 如果您将其视为git拥有/控制的存储库,则可能需要向其添加其他存储库。 These are called submodules. 这些称为子模块。 It's a way of including one repository's contents into another. 这是将一个存储库的内容包含到另一个存储库中的一种方法。 Read enter link description here . 在此处阅读输入链接描述 Doing this means that everything will be under a single folder and if you clone the repository you'll get everything required for the project. 这样做意味着所有内容都将在一个文件夹中,并且如果您克隆存储库,则将获得项目所需的所有内容。

If you think of it as just a folder of stuff that Xcode uses then there is no reason that Xcode needs to refer to only one folder. 如果您将其仅视为Xcode使用的资料的文件夹,则没有理由Xcode只需要引用一个文件夹。 You can have multiple repositories cloned to different locations on your machine and files from each of them included in your project. 您可以将多个存储库克隆到计算机上的不同位置,并将项目中包含的每个存储库克隆到其中的文件。 In some ways this is simpler than submodules, but it limits you to always having each of the repositories cloned to the same (relative) locations (only really a concern when you're cloning to a different machine). 在某些方面,这比子模块要简单,但它限制了您始终将每个存储库都克隆到相同(相对)的位置(克隆到另一台计算机时才真正需要考虑)。

If you're working alone then the submodules approach may be more in-depth than you care for. 如果您是一个人工作,那么子模块方法可能比您关心的更深入。 If you're working in a team then it can be a boon (with instructions on what to do when updating the submodules doesn't work properly...). 如果您在团队中工作,那将是一个福音(有关更新子模块时无法正常工作的说明...)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用dropbox时在xcode中使用本地git存储库是否有意义? - does it make sense to use a local git repository in xcode while using dropbox? Xcode 4 中 Git 存储库的问题 - Problem with Git Repository in Xcode 4 返回的本地变量的内存管理 - Mem management for returned local variable 有效的配置文件不适用于git存储库 - Valid Provisioning Profile not working for git repository iPhone:如何重新创建XCode内置git存储库? - iPhone: How to re-create XCode built-in git repository? 使用XCode从macOsX上的git.videolan.org存储库构建MobileVLCKit - Building MobileVLCKit from git.videolan.org repository on macOsX with XCode git存储库:可以在Xcode外部访问以前的文件版本 - git Repository: Is Previous File Version Accessible Outside of Xcode Xcode的git存储库在哪里存储? 为什么在复制项目目录时会创建不同的存储库? - Where is git repository of Xcode stored? And Why different repository is created when I copy project directory? 在Xcode中删除本地文件后,如何与svn存储库同步项目? - How to synchronize a project with svn repository after deletion of local files in xcode? xcode4:如何使用“ git存储库”与不同计算机上的多个用户共享同一项目? - xcode4 : How to use “git repository” to share same project with multiple users on different computer?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM