怎么获取上次 push 操作时的 commitid

2018 年 7 月 17 日
 az09py

要对比本次 push 到上次 push 的 diff,怎么能获取到上次 push 操作的 commit 呢

3338 次点击
所在节点    程序员
16 条回复
az09py
2018 年 7 月 17 日
问题有点错误,应该是:在本次 push 时,获取最近一次的 pull/push 的 commit
geelaw
2018 年 7 月 17 日
你或许想要比较 remote/branch_name 和 local_branch_name
Keller0
2018 年 7 月 17 日
你可能需要看 commit 的 msg 或者 tag
malusama
2018 年 7 月 17 日
git log
Oneneuuu
2018 年 7 月 17 日
gitlog 外加文本过滤一下吧
rabbbit
2018 年 7 月 17 日
git reflog show origin/master
alvinbone88
2018 年 7 月 17 日
git rev-parse HEAD
gnaggnoyil
2018 年 7 月 18 日
这难道不是个 A-B 问题吗……

`git diff HEAD~1 HEAD`
gnaggnoyil
2018 年 7 月 18 日
s/A-B 问题 /X-Y 问题 /g
siteshen
2018 年 7 月 18 日
还是不太明白"最近一次的 pull/push 的 commit",不过下面的命令能得到远端分支的最后一个 commit

git fetch; git rev-parse origin/${BRANCH}
az09py
2018 年 7 月 18 日
@siteshen 恩恩 我也发现直接获取远程分支最后一个 commit 更好
az09py
2018 年 7 月 18 日
@gnaggnoyil 这个是这次 commit 和上次 commit 的吧
az09py
2018 年 7 月 18 日
@geelaw 恩恩 是我没表达清楚 谢谢
az09py
2018 年 7 月 19 日
@siteshen 请问大佬 获取远端跟踪分支最后一个 commit,有没有不要${branch}的命令,或者有没有获取当前跟踪分支名的命令呢
siteshen
2018 年 7 月 19 日
@az09py `$(BRANCH}` 替换为 `$(git rev-parse --abbrev-ref HEAD)` 就行。

另外 @gnaggnoyil 说的 X-Y 问题应该是这个: https://coolshell.cn/articles/10804.html
意思是也许直接问你要解决的(完整的)问题,比问一个你提出的解决方案的一部分更好。
az09py
2018 年 7 月 21 日
@siteshen 谢谢!

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/471756

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX