一、分支管理
0. 远程仓库管理
$git init
$git remote add origin 远程仓库地址
$git remote origin
$git pull origin master
1. 查看分支
- 列出本地分支:git branch
- 列出所有分支(本地+远程):git branch -a
2. 创建分支
- 创建分支:git branch <你的分支名称>
- 切换分支:git checkout <你的分支名称>
- 创建+切换分支:git checkout -b <你的分支名称>
- 从git上一般拉下来都是master,直接拉目标分支:git checkout -b
<本地分支名> <远程分支名>
3. 关联分支
- 查看本地分支与远程仓库分支的跟踪关联关系:git branch -vv
- 更改本地分支和远程分支的关联追踪关系:git branch --set-upstream-to origin/远程分支名 本地分支名
二、统计
1、查代码行数
git log --format='%aN' | sort -u | while read name; do echo -en "$name\t"; git log --author="$name" --since ==2018-05-24 --until=2018-06-23 --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 }' -; done