Git 找出我推送的最后一次提交

标签 git

我想找出我推送的最后一件事,不是我提交的最后一件事,而是推送的。

是否有用于此的 git 命令?

上下文: 我想在将我的 dev_branch 与 master 分支 merge 之前压缩一些提交,但有人告诉我你不能 rebase 任何已经推送的东西(这是真的吗?)。

所以我想知道我不能包含在此 rebase 中的最后一次提交是什么。

最佳答案

如果你指的是你推送到 master 分支的最后一次提交,那么假设你的 Remote 是 origin:

git rev-parse origin/master

这将向您显示 origin 来源的 master 分支尖端的提交 ID,您的本地存储库当前知道。 这可能意味着该提交是其他人的提交,如果其他人在您之后推送了提交并且您已经fetch编辑了该分支。

git show -p origin/master

此命令将为您提供有关提交的信息,包括提交 ID、作者、日志消息以及与其父提交的差异。


我最喜欢执行这种检查的 Git 命令之一:

git log --pretty=oneline --abbrev-commit --graph --decorate --all

这将显示提交历史的漂亮 ASCII 艺术图,并且每个提交都将显示任何以它为目标的引用。通过这种方式,您可以一目了然地查看历史记录中的分支和 merge ,并轻松查看 origin/master 与您自己的 master 相关的位置。

关于Git 找出我推送的最后一次提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15552063/

相关文章:

git 8728 fork : child -1 - died waiting for longjmp before initial

git - 阻止 git 处理 "safe deleting"未 merge 的分支

git - 有没有办法让 git 为审查板创建补丁?

Git 不跟踪文件夹

git - fork 的 git repo 的端口功能到原始的而不 pull 入整个 fork 的 repo

windows - 配置 Jenkins 以在 Windows 上使用 GIT,得到 stderr : Permission denied (publickey)

asp.net - 如何 merge 并提交到 TeamCity 中的分支

git - 如何拆分包含重构的 Git 提交?

git - 使用 git-plus 后 Atom 文件颜色不同

ruby-on-rails - 更改 git 的 Remote 在 digital ocean 上不起作用