Git 统计代码量

最近有一个需求是要统计 Git 仓库里每个人的代码量,于是上网搜了一下,找了一些相关命令:

指定用户名版

git log --author="_Your_Name_Here_" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -

这句话可以输出当前项目内指定用户名的用户的代码量统计,结果如下:

added lines: 30400 removed lines: 21317 total lines: 9083

使用 ls-file 实现不指定用户版统计行数版

git ls-files -z | xargs (更多…)

git commit 出现There was a problem with the editor ‘vi’

今天在Mac OS X 10.9.3上使用git的时候遇到这么一个问题,执行git commit操作会显示如下错误:
There was a problem with the editor ‘vi’

搜寻了一下相关的解决方案,发现好多人遇到了这个问题。似乎是因为vim的返回值有问题导致的。
所以执行一下下面这条命令:
$ git config –global core.editor /usr/bin/vim
将git使用的编辑器强制指定一下,就可以正常使用了。具体的错误分析就不翻译了,贴在下面:

I have had an annoying problem with git and vi. I like to use vim to edit my commit messages, but I’ve been hit with this annoying message (更多…)

Git教程系列-详细版(转载收藏)

http://blog.enjoyrails.com/2008/12/28/git%E8%AF%A6%E8%A7%A3%EF%BC%88%E4%B8%80%EF%BC%89/

http://www.5iphp.com/node/124

 

流程:取代码 → 每次工作前更新代码到最新版本 → 修改代码 → 提交代码到服务器

取代码及修改全局设置

设置用户名与邮箱

1
2
git config --global user.name "My Name"
git config --global user.email "my@email.com"

从已有的git库中提取代码

1
git clone git@server:app.git myrepo

每次更改代码的操作

更新本地代码到最新版本(需要merge才能合到本地代码中)