TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Git is cheap

113 点作者 beghbali超过 12 年前

7 条评论

skrebbel超过 12 年前
I strongly half-agree here.<p><i>Commit early</i>, hell yeah!<p><i>Branch often</i>, umm, no. I feel that the excellent branching features of modern DVCSes have made people lazy and afraid to confront the inherent concurrent nature of working in parallel with people on the same codebase. Sure, if you're a 200 person team, there might be no way around it some decent branching setup. But don't forget: <i>every feature branch means postponing continuous integration</i>.<p>Continuous integration is the <i>core</i> of any productive and effective agile-ish team. Daily standups are nice, backlogs are lovely, but without continuous integration you can't get that design-develop-test cycle short enough to deploy/demo early and often.<p>Therefore, when working on a product or component with a limited team size (say, up to 15 people that are in close contact with one another), I believe that it is best to get your code on the mainline <i>as fast as possible</i>. Often, in git terms, the simplest way to do this is simply directly committing and pushing to master. Doing this helps signal conflicting concurrent work early, and it helps avoid double work. It encourages necessary but unforeseen design sessions <i>before</i> the work is done, rather than refactoring sessions afterwards.<p>The only strong downside to super-fast continuous integration that I can see is the chance that you "break the build" (or the tests, or whatever your situation has that needs to be OK for developers to be able to add features). If the team is in close contact, this is typically fixed within minutes ("hey Mike, you broke xyz.cpp" "oh damn, sorry, i'm right on it"), and if it isn't, well, git has cherry-picking features for a reason! You can use the tools to avoid the broken code for a few hours until the guy who broke it is back from the hairdresser.<p>Sure, you can do good CI with feature branches, but people have to be disciplined, and push their feature branch with master very often. Like, multiple times per day. I've never seen that work in practice. This doesn't mean that it can't work in practice, but it does mean that "branch away, buddy!" may be bad general advice.<p>When committing straight to master, the danger is of course that people hold back pushing their commits over the line entirely, which is bad too, but I find that once the horrible, horrible "whoever breaks the build gets pie" rule is replaced by the "whoever pushes more than x changed files/lines at a time gets pie" rule turns that culture around just fine.<p>I'll be the first to admit that this might work less well with e.g. highly distributed teams in different timezones. But that's hardly the most common scenario.<p>Continuous integration is called that for a reason. If you do A-few-times-a-week-integration, then call it that. And in my opinion, you're missing out.
评论 #4657179 未加载
评论 #4657471 未加载
评论 #4656866 未加载
评论 #4656999 未加载
评论 #4656897 未加载
评论 #4656875 未加载
评论 #4658512 未加载
评论 #4656975 未加载
评论 #4656972 未加载
评论 #4659218 未加载
评论 #4656797 未加载
评论 #4661171 未加载
campo超过 12 年前
I absolutely agree with this. I recently started working on a small web app as a side project. I was dealing with a lot of elements that were new to me and was constantly pushing the limits of my knowledge and breaking things. I realized I wasn't using the power git provided me with branches.<p>Once I started branching things got quicker and more effective because I could bounce between tasks without affecting my deployment (master branch). In five days of frantic coding using git branching I now have a clean easy deployment of about 750 lines, which I iterated on through four different branches and, probably over 3000 lines of code.<p>It's not perfect, but it's eliminated any apprehension about aggressively changing my application, and made me far more ambitious. I feel great about it.
评论 #4656489 未加载
doesnt_know超过 12 年前
There is another good reason to break commits down into small "bricks" (as the author calls them) and that is bisect[1]. Up until very recently I only used a tiny fraction of the git toolbox, but when I was complaining to a friend about how an app I was working on deployed fine on one machine but not on another with the exact same configuration he told me to run bisect.<p>It took me a matter of minutes to zero in on the exact commit that broke the app on that one machine. This would have been something I would have spent hours, possibly days trying to figure out by going over every tiny config detail (it wasn't a config issue).<p>Bisect is a powerful little tool to have in your back pocket when you know something you introduced at <i>some time</i> broke <i>something</i> and you need to find out what. The smaller and more "relevant" you keep your commits, the easier it will be to use. Obviously the opposite is true, if you have these massive commits which change large amounts of different files and/or multiple features, bisect becomes significantly less useful, almost worthless.<p>[1] <a href="http://git-scm.com/docs/git-bisect" rel="nofollow">http://git-scm.com/docs/git-bisect</a>
prawks超过 12 年前
As this is a positive article about git, if the OP reads this, I'd suggest using the word "inexpensive" next time. Cheap often has a negative connotation that something is low-cost at the expense of quality.<p>Just a pet peeve. Git is most certainly not cheaply made.
评论 #4656992 未加载
评论 #4657200 未加载
评论 #4657122 未加载
评论 #4656819 未加载
tocomment超过 12 年前
Is there any best practice for a large team of 50 developers to work in Git? We have about 20 separate (almost completely separate) projects.<p>We currently have everything under one big SVN directory. I use git for personal stuff so it's always a pain to work in SVN.
评论 #4657032 未加载
评论 #4656963 未加载
评论 #4657222 未加载
评论 #4657359 未加载
评论 #4661234 未加载
评论 #4658619 未加载
评论 #4657002 未加载
rkangel超过 12 年前
He compares it to SVN, but makes a classic error. In SVN branches and commits are just as cheap as in git (albeit marginally slower to create usually). It's the <i>merges</i> that are expensive.<p>It's there that git wins, with it's better understanding of how content moves around, and the ability of the merge tool to see the history and identify the common ancestor.
评论 #4658622 未加载
评论 #4658786 未加载
ripperdoc超过 12 年前
Sorry for going off-topic, but I tried to open this on iPhone and it never finished loading. It's 1.25 MB for one page of 3500 chars of text. Maybe the ratio of polish vs content is a bit too skewed here?
评论 #4659128 未加载