简体   繁体   English

你如何在“独奏开发”中使用git(没有团队)?

[英]How do you use git in “solo-development” (without team)?

I work as a freelancer on small projects, and all of them I'm doing alone, without a team. 我是小型项目的自由职业者,所有这些都是我独自完成的,没有团队。

I tried to use the Git Flow. 我试着使用Git Flow。 At first, all was well. 起初,一切都很好。 There were branches for features, small commits with meaningful description, merges. 有功能分支,有意义描述的小提交,合并。

But the process always ends with enormously large commits direct to master branch, with descriptions like "big update", "some update". 但是这个过程总是以非常大的提交结束,直接到主分支,描述如“大更新”,“一些更新”。

How do you deal with it? 你如何解决? Do I need Git Flow in my case or not? 在我的情况下我是否需要Git Flow?

But the process always ends with enormously large commits direct to master branch, with descriptions like "big update", "some update". 但是这个过程总是以非常大的提交结束,直接到主分支,描述如“大更新”,“一些更新”。

This is what git rebase --interactive and git add --patch are for. 这就是git rebase --interactivegit add --patch的用途。

Here's the first thing you've got to do: you have to make yourself a crazy person. 这是你要做的第一件事:你必须让自己成为一个疯狂的人。 No, two crazy people, each convinced the other is someone else. 不,两个疯狂的人,每个人都说服对方是别人。 No, wait, that's not right. 不,等等,那不对。 Three crazy people. 三个疯狂的人。

There's the (currently sane) you you already know, who's done this work and doesn't see anything else to say about it. 你已经知道了(目前是理智的),谁完成了这项工作,并没有看到任何其他说法。 So: the first step to a crazy you and a sane history is the new (but purely imaginary fragment of) you the code reviewer, who knows absolutely nothing about the changes you've made until she sees the commit message and the patch. 所以:疯狂的你和一个理智的历史的第一步是代码审查员的新的(但纯粹想象的片段),他对你在看到提交消息和补丁之前所做的改变一无所知。 You need to be respectful of that person's time. 你需要尊重那个人的时间。 The third part, that takes this from useful quirk to full-on insanity, is the rubber duck . 第三部分,从有用的怪癖到全面的精神错乱,是橡皮鸭 It's an open question whether carrying around an actual rubber duck or simply having an imaginary confidante that just happens to be a rubber duck is more disturbing to others' sense of reality (to say nothing of your own). 这是一个悬而未决的问题,无论是携带一只真正的橡皮鸭,还是仅仅想象一下恰好是橡皮鸭的想象中的红颜知己,对其他人的现实感(更不用说你自己)更令人不安了。

So, two crazy people and a duck. 所以,两个疯狂的人和一只鸭子。

If the rubber duck can't understand your explanation, or the reviewer can't understand your code, then simplify until they can. 如果橡皮鸭无法理解您的解释,或者评论者无法理解您的代码,那么请简化,直到他们可以。 Break up the commits into independent parts that don't break the build and don't leave the reviewer or the duck wondering why everything in each needs to be there to keep everything working right. 将提交分解为不会破坏构建的独立部分,不要让审阅者或者鸭子想知道为什么每个部分都需要在那里保持一切正常。

See, if you set it up so doing the right thing has massive entertainment value, the world will be good. 看,如果你进行了设置,那么做正确的事情具有巨大的娱乐价值,世界将是美好的。 If you don't, it'll be by comparison at least unpleasant and boring. 如果你不这样做,那么至少会令人不快和无聊。 The only time not to do this is when you can already feel how badly you're going to need this stuff done right in a few months, then it's just a waste of time. 唯一不这样做的时候就是你已经感觉到在几个月内你需要做这件事有多糟糕,那只是浪费时间。 But if you're going to lose it, make sure you get something even more valuable in exchange. 但如果你要失去它,请确保你获得更有价值的东西作为交换。

rebase and add are necessary whether you're having fun or not. 无论你是否玩得开心,都需要改装和添加。

It's a matter of discipline, I guess. 我想这是纪律问题。

To me it's very useful to have small commits that describe the exact change they contain. 对我来说,使用描述其包含的确切更改的小提交非常有用。 I use this flow in my work environments where I work with a team, but also for projects that I do as a hobby or for projects on the side. 我在我与团队合作的工作环境中使用此流程,但也用于我作为业余爱好或项目的项目。

It helps if you have a graphical UI. 如果您有图形用户界面,它会有所帮助。 I use Atlassian SourceTree, which makes it very easy to select changes to the line. 我使用Atlassian SourceTree,它可以很容易地选择对行的更改。 So sometimes I've been coding for a while, making lots of changes, and I will still stage them one by one and commit each change with a useful message. 因此,有时候我已经编写了一段时间,进行了大量的更改,我仍然会逐个进行编写,并使用有用的消息提交每个更改。

But it's better to do one change at a time, verify that it works and commit that. 但最好一次做一个更改,验证它是否有效并提交。 If you commit often, you always have something to go back to if you make a big error. 如果你经常提交,如果你犯了很大的错误,你总会有一些东西要回去。

Personally, I don't use the development, release and other verbs of git flow, although I do create separate branches for the different features I develop. 就个人而言,我不使用git flow的开发,发布和其他动词,虽然我确实为我开发的不同功能创建了单独的分支。 That allows me to put changes aside while they are in progress and to make separate pull requests (which is probably more useful in a team). 这允许我在进行中时将更改放在一边并进行单独的拉取请求(这在团队中可能更有用)。

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

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