git Git找出我推送的最后一次提交
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15552063/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git find out the last commit i pushed
提问by chrispepper1989
I want to find out the last thing that I pushed, not the last thing i commited, but pushed.
我想找出我推送的最后一件事,不是我提交的最后一件事,而是推送的。
Is there a git command for this?
有 git 命令吗?
Context:I want to squash some commits before merging my dev_branch with a master branch but I have been told you can not rebase anything that is already pushed (is this true?).
上下文:我想在将我的 dev_branch 与 master 分支合并之前压缩一些提交,但我被告知您不能重新设置任何已经推送的内容(这是真的吗?)。
So i would like to know what was the last commit that I cannot include in this rebase.
所以我想知道我不能包含在这个 rebase 中的最后一次提交是什么。
回答by cdhowie
If you mean the last commit you pushed to the master
branch then, assuming your remote is origin
:
如果你的意思是你推送到master
分支的最后一次提交,那么假设你的遥控器是origin
:
git rev-parse origin/master
This will show you the commit ID of the tip of the master
branch of the origin
origin, as your local repository is currently aware.This may mean that the commit is someone else's commit, if someone else pushed commits after you did and you have since fetch
ed that branch.
这将向您显示源master
分支尖端的提交 ID origin
,因为您的本地存储库当前是知道的。这可能意味着提交是其他人的提交,如果其他人在您完成之后推送了提交并且您已经fetch
编辑了该分支。
git show -p origin/master
This command will give you information about the commit, including the commit ID, author, log message, and diff to its parent commit(s).
此命令将为您提供有关提交的信息,包括提交 ID、作者、日志消息以及与其父提交的差异。
One of my favorite Git commands for doing exactly this kind of inspection:
我最喜欢执行这种检查的 Git 命令之一:
git log --pretty=oneline --abbrev-commit --graph --decorate --all
This will display a nice ASCII-art graph of the commit history, and each commit will show any refs that are targeting it. This way you can, at a single glance, see branches and merges in history and easily see where origin/master
is in relation to your own master
.
这将显示提交历史的漂亮 ASCII 艺术图,并且每次提交将显示针对它的所有引用。通过这种方式,您可以一目了然地查看历史记录中的分支和合并,并轻松查看origin/master
与您自己的master
.