Git Search

Git查看分支从哪个分支创建的

查看分支创建时间

1
git reflog show --date=iso <branch name>

举例如图:

查看Git分支从哪创建

最老的那条记录即可以看出是从哪创建出来的。

但有时候记录太多,滑动太长,可以直接使用如下命令,直接查看

1
git reflog dev_environment | grep "Created from"

如果是feature分支

1
git reflog show --date=iso feature/设备小程序

image-20220301145230642

Git项目管理

Git项目管理

一、Git统计提交代码量

1
2
3
git log --author="_your_name_" --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 }'

git log --author=xxxxx --since=‘2023-01-18 00:00:00’ --until=‘2023-01-18 23:00:00’ --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 }’

git log 查询git的提交记录

–author=xxx 查询某一个用户的提交记录

–pretty=tformat: 控制显示的记录格式

–numstat 对增加和删除的行数进行统计 第一列显示的是增加的行数 第二列显示的是删除的行数

–since 需要统计的开始时间

–until 需要统计的结束时间

实操:

1
2
3
4
5
6
7
8
9
10
# 常量形式
git log --author="qian" --since='2023-02-18 00:00:00' --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 }'

# 变量形式
authorName=qian
sincedate='2023-02-18 00:00:00'
git log --author="$authorName" --since="$sincedate" --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 }'

# 增加统计多少个文件
git log --author="$authorName" --since="$sincedate" --pretty=tformat: --numstat | awk '/./ { add += $1; subs += $2; loc += $1 - $2 } END { printf "modified files: %s, added lines: %s, removed lines: %s, total lines: %s\n", NR, add, subs, loc }'