简体   繁体   English

我最近一次提交和最后一次提交之间的git diff

[英]git diff between the latest commit and the last one I did

so, I can easily get the diff between two commits by using 因此,我可以使用轻松获得两次提交之间的差异

git diff hash_old hash_new file git diff hash_old hash_new文件

that works, but in my current workflow my diffs are invariably between the latest commit and my commit. 可以,但是在我当前的工作流程中,我的差异总是在最近的提交和我的提交之间。 is there a way to automate that with a shell alias so that i don't have to manually copy the two hashes but instead always pick the latest with my name or email and compare it against the latest in line? 有没有一种方法可以使用shell别名自动执行该操作,这样我就不必手动复制两个哈希,而总是选择带有我的姓名或电子邮件的最新哈希值并将其与最新的行进行比较?

I tried to do this by subsetting the output of git diff through a shell function and then creating an alias, but not sure the output is stored as an array. 我试图通过使用shell函数将git diff的输出设置为子集,然后创建一个别名来做到这一点,但是不确定输出是否存储为数组。 any suggestions? 有什么建议么?

这可能是最短的解决方案,也是最稳定的解决方案,因为它使用低级helper命令进行历史记录遍历):

git diff $(git rev-list --author="Your Name" -1 HEAD) HEAD

Try this: 尝试这个:

$ git log -1 --pretty=format:"%h" --author=<name> | xargs git diff

Replace <name> with your git user-name . <name>替换为您的git user-name

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在第一次和最后一次提交之间的同一文件中使用git diff - Using git diff in same file between first and last commit 上次提交和上次提交之前的提交之间的区别? - Diff between last commit and commit before last commit? 在我做了git rebase后,它应该只有一个提交 - after I did git rebase it should so only one commit 我如何让Jenkins存档上一版本和最新版本之间的git差异? - How can I get Jenkins to archive git difference between last build and latest one? 查看当前状态和上次提交之间的差异 - See diff between current state and last commit HEAD和最后一次提交之间的git diff提供警告:忽略悬空的symref - git diff between HEAD and last commit gives Warning: ignoring dangling symref git diff是否在索引和工作副本之间或在最后提交和工作副本之间进行比较? - Does git diff compare between index and working copy or last commit and working copy? 特定提交和本地文件之间的git diff - git diff between specific commit and local file 如何使用 gitpython 对当前提交与上次提交进行 git diff 比较? - how to do a git diff of current commit with last commit using gitpython? 如何确认当前git diff是当前和最后一个,而不是当前提交和其他任何一个 - how to confirm that current git diff is one with current and last and not with current commit and any other
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM