如何查看我参与的所有仓库中已推送的全部commit记录?
查看所有参与仓库的已推送Commit记录方案
本地批量查询方法
方法1:指定仓库列表批量遍历
- 把你参与的所有仓库绝对路径整理到一个文本文件,比如
repo_list.txt,每行一个路径:/home/user/projects/repo1 /home/user/projects/repo2 - 运行以下Shell脚本(替换成你的Git邮箱):
#!/bin/bash YOUR_EMAIL="your-git-email@example.com" while read repo_path; do echo "=== 仓库: $repo_path ===" # 筛选你作为作者的所有已推送commit,简洁显示哈希和提交名称 git -C "$repo_path" log --author="$YOUR_EMAIL" --oneline --all done < repo_list.txt
方法2:自动遍历目录下所有Git仓库
如果你的所有仓库都在同一个父目录(比如~/projects),可以直接自动遍历:
#!/bin/bash YOUR_EMAIL="your-git-email@example.com" find ~/projects -type d -name ".git" | while read git_dir; do repo_path=$(dirname "$git_dir") echo "=== 仓库: $repo_path ===" git -C "$repo_path" log --author="$YOUR_EMAIL" --oneline --all done
自定义显示格式
如果需要更详细的信息(比如提交日期),可以替换--oneline为自定义格式:
git -C "$repo_path" log --author="$YOUR_EMAIL" --pretty=format:"%h %cd %s" --date=short --all
%h:短哈希值%cd:提交日期(--date=short简化为YYYY-MM-DD格式)%s:提交名称(commit信息标题)
注意事项
- 确保替换
YOUR_EMAIL为你Git配置中的邮箱,避免漏筛或错筛 - 运行脚本前,对每个仓库执行
git fetch --all拉取最新远程分支,确保本地包含所有已推送的commit记录
内容的提问来源于stack exchange,提问作者user20239412
相关产品推荐
相关产品推荐

