git - 获取最近推送的提交的 github URL
问题描述
在下面的简化示例中,我有一个将提交推送到开发分支的模式:
git status // Let's see what I did
git add . // I want to commit all my changes
git commit -m "I did a thing" // I commit with a message
git pull --rebase origin dev // I am trying to avoid a merge conflict
git status // I am really ready to push, right?
git push origin dev // I am pushing to github
现在我看不出这种模式有什么问题(也许我应该?),但我想快速将链接放到我在其他地方提交的 github URL 的链接。
理想的输出,我想这就像改变这个git push
输出:
To https://github.com/MyGithub/MyRepo
aaa0001..aaa0000 dev -> dev
到
To https://github.com/MyGithub/MyRepo/path/to/latest/commit
aaa0001..aaa0000 dev -> dev
解决方案
你在用bash
吗?git log
使用推后的输出怎么样?
$ echo https://github.com/user/project/commit/$(git log --format="%H" -n 1)
https://github.com/user/project/commit/7e30ecbffa4ce37d0cb9e2d10682ce8fa0b24e4b
推荐阅读
- javascript - 无法导入 ES6 模块
- angular - Angular:按计数创建两列
- haskell - 未能捕获“纯”函数引发的异常
- python - 如何组织已下订单
- matlab - Matlab 颜色图和 caxis 匹配非线性图
- amazon-web-services - 监控从 Glacier 到标准存储的批量转换?
- angular - 如何使用基于 webpack 的设置在 Angular 应用程序中加载外部库
- javascript - 为什么我应该调用 Function.prototype.apply.call(x, ...) 而不是 x.apply(...)?
- sql - 如何从 db 变量名中获取表名?(SQL)
- sql - 单个 where ... like 子句中的多行