每次 commit 之前再自己 review 一遍代码是个好习惯

2014-07-02 22:21:44 +08:00
 Livid
最近一年多来养成的一个习惯,就是每次 commit 之前,一定会在 GitX 里把要 stage 的更改再看一遍,而且 GitX 有一个好功能就是,你可以不用 stage 整个文件,你可以只 stage 某个函数中更改了的一个部分。

如果你还在用 git commit -a 的话,或许你可以考虑一下让自己的 commit 冲动慢一点,这样对代码质量会有好处。
9329 次点击
所在节点    git
70 条回复
Bluecoda
2014-07-03 11:21:05 +08:00
这么多SourceTree,用tig的有点另类啊。有没有朋友介绍一下SourceTree比tig优势在哪里?
chshouyu
2014-07-03 11:27:18 +08:00
可以试试git add -p
可以精细的控制要提交的内容
y - stage this hunk
n - do not stage this hunk
q - quit; do not stage this hunk nor any of the remaining ones
a - stage this hunk and all later hunks in the file
d - do not stage this hunk nor any of the later hunks in the file
g - select a hunk to go to
/ - search for a hunk matching the given regex
j - leave this hunk undecided, see next undecided hunk
J - leave this hunk undecided, see next hunk
k - leave this hunk undecided, see previous undecided hunk
K - leave this hunk undecided, see previous hunk
s - split the current hunk into smaller hunks
e - manually edit the current hunk
? - print help

GUI程序当然更好用一点
lazyphp
2014-07-03 11:40:38 +08:00
git commit -m 之前必须确认好 没搞错。 在这过程之前的所有操作都可以快速还原的。。。
rannnn
2014-07-03 11:50:31 +08:00
公司里面的ci build一次要半个小时。。。每次commit都是胆颤心惊的看了一遍又一遍生怕搞挂了。
skywalker
2014-07-03 11:58:14 +08:00
magit +1
hutushen222
2014-07-03 12:22:00 +08:00
SourceTree +1
pepsin
2014-07-03 12:24:27 +08:00
都是用 Github 那个客户端,每次都是通读一遍变更才出去。这不是基本素养么。
suprod
2014-07-03 12:28:03 +08:00
Tigtigtigtigtigtigtigtig
est
2014-07-03 12:34:58 +08:00
commit错了revert 然后 reset呗。
reorx
2014-07-03 12:48:06 +08:00
没错,自从用了 GitX 之后,review 和 commit 都变得更清晰了,即便一次写很多代码,也可以非常方便地拆分成多个 commit 了。个人感觉比 SourceTree 好用,btw,我用的是这个 fork: http://rowanj.github.io/gitx/
qichunren
2014-07-03 13:00:37 +08:00
GitX可以选中文件中的行来提交,非常好用。
breeswish
2014-07-03 13:14:34 +08:00
自从有了 SourceTree, 其他方式再也不用了.. 而且还是免费的
finian
2014-07-03 13:15:04 +08:00
@wecoders SourceTree是免费的啊
finian
2014-07-03 13:15:41 +08:00
SourceTree +1
toctan
2014-07-03 13:26:01 +08:00
magit 秒了所有…
chemzqm
2014-07-03 13:38:16 +08:00
alias gca="git commit -a -v"
一般都是gca,gitx看各种分支线挺方便
taobeier
2014-07-03 14:02:38 +08:00
git commit -a 不是什么好习惯
66beta
2014-07-03 14:12:30 +08:00
Github客户端可以当第三方用
jianghu52
2014-07-03 15:48:49 +08:00
看了一圈,没一个人用TortoiseGit ,我是不是太low了?但是我确实觉得小乌龟很好用啊。尤其是还可以有中文版。
bigporker
2014-07-03 16:25:45 +08:00
@yangqi 确实团队会定期组织同事之间互相review已经提交到代码仓库里的代码

有的团队在提交时就要求两人review
尤其是修改设计到别人负责的模块时

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/120681

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX