bash - 将修改文件列表放入 git commit 消息中
问题描述
我正在尝试向我添加一个别名.gitconfig
,它将自动将当前存储库中的所有修改文件添加到提交消息中。
我尝试处理git status --porcelain
usingcut
和的输出awk
。
我开始awk
工作了,但我确信有更好的解决方案可以产生更好的提交消息。
# in my .gitconfig
g = !git commit --all --message "edited:$(git status --porcelain | awk '{printf \"%s%s\",(NR>1?\",\":\"\"),$2} END{print \"\"}')"
# on the command-line
git commit --all --message "edited:$(git status --porcelain | awk '{printf \"%s%s\",(NR>1?\",\":\"\"),$2} END{print \"\"}')"
从git log
,我看到提交消息,如edited:dir1/file1,dir2/file2
.
我想清理代码和/或改进提交消息。
解决方案
该信息已经在您的提交中可用。你只需要跑git log --stat
去看它。
我经常使用它,以至于我在我的.gitconfig
:
[alias]
ls = log --stat
所以每当我使用时,git ls
我都会得到统计输出。
推荐阅读
- node.js - Deprecation Warning Error with Blockchain
- html - 需要使用 Html.Action 传递参数和 csslink
- javascript - 如何解码 Minecraft 示意图(nbt)文件中的数据(即块状态)字节?
- html - 在 h-100 列内垂直对齐图像
- swift - 为什么在将协议约束到类时不能使用协议所需的初始化程序?
- vb.net - 循环遍历不同类型对象的组合列表
- sql - 等待锁定对象时出现超时错误
- javascript - 承诺:跳过所有的完成和拒绝反应,但执行 .finally
- scala - 为什么包对象中类型的类名在运行时类名中包含“包”?
- python - 如何在不使用任何内置函数的情况下查找一个数字在列表中出现的次数