获取最新推送的github URL

时间:2018-11-29 19:00:07

标签: git github

在下面的简化示例中,我有一种将提交推送到dev分支的模式:

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

1 个答案:

答案 0 :(得分:1)

您是否使用bash?推送后如何使用git log的输出?

$ echo https://github.com/user/project/commit/$(git log --format="%H" -n 1)
https://github.com/user/project/commit/7e30ecbffa4ce37d0cb9e2d10682ce8fa0b24e4b