简体   繁体   English

将iOS xcode文件提交到Github的一般规则

[英]General Rules for commiting iOS xcode files to Github

I recently came across a situation where a colleague basically threw a fit when I committed about 12 *.h and 12 *.m and a bunch of images(assets) to github. 我最近遇到了这样一种情况,当我将大约12 * .h和12 * .m以及一堆图像(资产)提交给github时,一位同事基本上就适合了。 The 12 files included a few .xib files. 这12个文件包括一些.xib文件。 The total changes (including the images and xib xml code) came to around 985 changes. 总更改(包括图像和Xib xml代码)达到985个更改。 The 985 lines were mostly because the .xib files were getting converted to xml code. 985行主要是因为.xib文件已转换为xml代码。 The colleague said that the checkin was too huge. 同事说值机太大。 I am a little surprised to see this reaction as I didnot think 24 files comprised was a HUGE checkin, or is this truly against the rules for committing to github. 我对此反应感到有些惊讶,因为我不认为包含的24个文件是巨大的签入,或者这确实违反了提交github的规则。 I have used SVN most of my life and worked in large teams where I never came across this issue. 我一生中大部分时间都在使用SVN,并且曾在大型团队工作,但从未遇到过此问题。 I am working on a 2 person team and a recent user to git. 我正在2人团队和git的最近用户上工作。 Am wondering if I indeed need to change the way I commit? 想知道我是否真的需要更改提交方式? Any suggestions? 有什么建议么?

-Thanks -谢谢

I also read through the discussion, and what he is asking definitely looks like the exception, not the norm, especially for a small team of only two people. 我也阅读了整个讨论,他的要求肯定看起来像是例外,不是常态,特别是对于只有两个人的小团队而言。 There are indeed some rules to go by, but they are just common sense for good software engineering. 确实有一些规则需要遵循,但是对于良好的软件工程来说,它们只是常识。 I don't want to go outside the scope of your question, because if we start talking about all the various uses for different types of branches, we could talk for days. 我不想超出您的问题范围,因为如果我们开始谈论不同类型分支的所有各种用途,那么我们可能要讨论几天。

I would present an argument to your colleague by first discussing what you want to achieve by the commits, followed by an approach that can enable that to happen. 首先,通过讨论您想通过提交实现的目标,然后通过一种可以实现此目标的方法,向您的同事提出一个论点。 And it should be a dialog--who knows, if your discussing his objectives, you may find that it is beneficial to go his route. 而且应该是一个对话-谁知道,如果您讨论他的目标,您可能会发现走他的路线是有益的。 Hopefully, you will find a common ground that satisfies all of the most important objectives. 希望您会找到满足所有最重要目标的共同点。 When you come to an agreement, you should draw up some guidelines together, and make a copy for both. 达成协议时,您应该共同制定一些准则,并为两者制定一份副本。 It might seem easy to remember them at the time because they are logical, but at that same moment, you also might be making compromises that don't seem so logical weeks or months later. 由于它们是合乎逻辑的,因此在当时似乎容易记住它们,但与此同时,您可能还在做出折衷,而这些折衷在几周或几个月后似乎并不合逻辑。

Objectives 目标

  1. Developers should be able to go to a commit without the hassle of arriving at a point in the project that contains build errors. 开发人员应该能够进行提交,而不必麻烦到达项目中包含构建错误的地方。 This also allows a more efficient, productive, and stress-free development environment. 这也提供了一个更高效,多产且无压力的开发环境。 紧张的开发环境
  2. Developers should be able to go to a commit with the confidence that it is without bugs. 开发人员应该能够毫无风险地进行提交。 Any development that is built on buggy code, cannot be stable. 任何基于错误代码的开发都是不稳定的。 It's like building a house--the foundation has to be solid, or everything built on top of it may crumble. 就像盖房子一样-基础必须牢固,否则建在其上的一切都可能崩溃。 坚实的基础
  3. Developers should be able to go to any commit, and have a clear understanding of the contents and scope, by reading the commit comment. 通过阅读提交注释,开发人员应该能够进行任何提交,并对内容和范围有清晰的了解。
  4. Developers should be able to easily and quickly select a commit with confidence, without trial and error. 开发人员应该能够轻松,快速,自信地选择提交,而无需反复试验。

Approach 途径

  1. Commits should contain a cohesive set of files and code. 提交应包含一组内聚的文件和代码。 This means implementation files should be committed with the header files and assets that go along with them. 这意味着应将实现文件与头文件和资产一起提交。 Otherwise, a commit could have build errors when implementation is calling methods that aren't yet declared, or a developer will be at a loss when looking at a declaration in a header that's not being used anywhere in the project. 否则,当实现调用尚未声明的方法时,提交可能会产生构建错误,否则开发人员在查看未在项目中任何地方使用的标头中的声明时会感到茫然。 Your commits should tell a story of how you're progressing towards the end product. 您的提交应该讲述一个有关您如何向最终产品发展的故事。 Each commit will affect how efficiently and accurately you can roll back to fix any bugs. 每次提交都会影响您回滚以修复所有错误的效率和准确性。
  2. Do not do commit a project that doesn't successfully build. 不要提交未成功构建的项目。
  3. Test your code, and retest. 测试您的代码,然后重新测试。 When introducing new objects in the repository, perform unit testing, starting with the objects that have the least number of dependencies. 在存储库中引入新对象时,请从具有最少依赖关系的对象开始执行单元测试。
  4. If you are making a small change that is cohesive, and can tell a part of the development story, then go ahead and commit it. 如果您进行的是一个有凝聚力的小更改,并且可以说出开发故事的一部分,那么请继续并提交它。 This will also allow you make a fresh start on a larger task, with the ability to reset changes to your working copy if something doesn't pan out, and you need to try something completely different. 这还使您可以重新开始一项更大的任务,并能够在某些方面无法解决问题时重置对工作副本的更改,并且您需要尝试完全不同的事物。
  5. Use tags if you have a lot of commits. 如果您有很多提交,请使用标签。 A few tags that are set over hundreds of commits can save a lot of time, as they allow developers to quickly and easily select a commit, to begin to pin point the cause of a bug. 设置了数百个提交的几个标签可以节省大量时间,因为它们使开发人员可以快速轻松地选择一个提交,从而查明错误的原因。
  6. Branches can be used also, for features that require a lot of work. 对于需要大量工作的功能,也可以使用分支。 This allows multiple teams to work on multiple features simultaneously, without stepping on each others' toes. 这样一来,多个团队就可以同时处理多个功能,而无需踩踏彼此的脚趾。 For a team of two, such as yours, this could also be beneficial, if you want to able to make multiple commits, on separate features. 对于两个团队(例如您的团队)来说,如果您希望能够在单独的功能上进行多次提交,那么这也可能是有益的。 For some logical use cases for branches, take a look at Source Tree, and create some branches with their different options on a local repository. 对于分支的某些逻辑用例,请查看“源树”,然后在本地存储库上创建具有不同选项的一些分支。 For me it was very instructional and provided a good framework for a lot of branching decisions. 对我来说,这非常有启发性,并为许多分支决策提供了一个很好的框架。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM