json - 某个分支的 git log 漂亮格式
问题描述
我正在尝试使用 git log pretty format 命令将日志输入到 json 文件中。目前我正在使用这个命令来获取特定的 git 属性:
git log --pretty="format:{commit:%h,%n merge:%p,%n author:%an,%n title:%s,%n body:%b,%n}">git_log.json
该命令的问题在于它获取系统中所有分支的日志并输入到 json 中。我只想使用这个命令来输入我可以以某种方式输入的某个分支的日志。
我尝试检查我想要注销的某个分支,然后使用该命令但它不起作用,因为它仍然显示所有现有分支的日志。这是我在 cmd 行中的失败尝试:
git checkout robotics/ashish_c/infrastructure
git fetch
git log --pretty="format:{commit:%h,%n merge:%p,%n author:%an,%n title:%s,%n body:%b,%n}">git_log.json
但它也给了我其他分支的日志文件。如何仅获取分支 robots/ashish_c/infrastructure 的漂亮格式日志文件?
解决方案
该命令的问题在于它获取系统中所有分支的日志并输入到 json 中。
那不应该是这样。git log
获取当前签出的提交的日志及其历史记录。git log --all
获取所有分支的日志。
Git 历史不是线性的,看起来您正在获取已合并到当前提交中的其他分支的历史。git log --graph --decorate
将向您展示真实的历史。
如何仅获取分支 robots/ashish_c/infrastructure 的漂亮格式日志文件?
git log robotics/ashish_c/infrastructure
我正在尝试使用 git log pretty format 命令将日志输入到 json 文件中。
必须引用 JSON 键和字符串。我删除了换行符以简化事情,这不是供人类使用的。而是尝试...
git log --format='{"commit":"%h", "merge": "%p", "author": "%an", "title": "%s", "body":"%b"},' > git_log.json
但这会让你没有包装[]
和尾随,
.
推荐阅读
- ruby-on-rails - 无法使用 minimagick Rails 打开活动存储图像附件
- c - C Bus Error with mmap,是什么问题
- kubernetes - 新的服务帐户令牌未签名
- r - MDFS 警告消息
- javascript - 使用用户脚本阻止一个或多个网站中的所有广告
- javascript - 如何防止 Object.prototype 中的修改?
- google-apps-script - 是否可以在 Google 表格脚本中触发单元格选择?
- google-cloud-monitoring - 控制台中 GCP 监控警报策略的 JSON 模拟
- ruby-on-rails - 在钩子导轨之前向活动作业添加属性
- android - 在没有 android studio 的情况下在 windows 上运行颤振的问题