git 根据版本号查看修改文件列表

2021-02-05  本文已影响0人  邱皮皮

根据作者筛选出最近 n 条 commit

git log --author=byron --max-count=5 --oneline
--author 根据作者筛选
--max-count 输出最大记录数
--oneline 单行格式 [hash] comment  --pretty=oneline --abbrove-commit简写  --pretty=format 可以自定义输出格式
image.png

根据版本号查看修改文件列表

git show ecb5e8ac --name-only --pretty=format:
--name-only 只展示文件名
--pretty=format: 自定义输出格式,会有一个空行
image.png

代码同步脚本

#! /usr/bin/bash
path=/home/byron/
project_path=/home/byron/code/

git=giit@git.wzl.com:byron/code.git
branch=dev

#同步文件git的过滤条件
#author:git提交作者
#max_count: 该作者最近几条commit
author=byron
max_count=5

#目标目录
target_path=/var/www/dev.byron.com/

#下载项目到本地服务器
#切换到指定目录
rm -rf $project_path
cd $path
git clone $git
cd $project_path
git fetch origin $branch
git checkout $branch

# xargs 参数说明
# -t 打印执行后的内容
# -i 以{}为占位符,接收标准输出的内容
git log --author=$author --oneline --max-count=$max_count | awk '{print $1}' | xargs git show --name-only --pretty=format: | sed "/^$/d" | uniq | xargs -t -i cp {} $target_path{}

#执行同步完成后的脚本
php $target_path/Console/clear_cache.php
php $target_path/Console/refresh_version.php

rm -rf $project_path

echo "sync success \n"

exit 0
上一篇 下一篇

猜你喜欢

热点阅读