English 中文(简体)
git:如何查看由推送引起的更改?
原标题:git: how to see changes due to push?

我无法确切地弄清楚如何查看远程代码库中由 push 更改了什么。 git log 显示了一系列提交,但这些提交是在本地代码库中进行的,并且在不同的时间进行了推送。我想知道哪些提交是每个特定 push 的一部分。

最佳回答

实际上,您可以从reflog中提取这些信息。 它不是远程仓库的完整历史记录,而是远程仓库分支的副本的历史记录。 因此,您将无法看到其他人对远程仓库所做的更改。这不是很漂亮,但您可以编写脚本使它变得更容易。

例如:

$ git reflog show origin/master
ca4f119 refs/remotes/origin/master@{0}: pull --rebase: fast-forward
d303ece refs/remotes/origin/master@{1}: pull --rebase: fast-forward
ce28c26 refs/remotes/origin/master@{2}: pull --rebase: fast-forward
0f71883 refs/remotes/origin/master@{3}: pull --rebase: fast-forward
8c2f0dd refs/remotes/origin/master@{4}: pull --rebase: fast forward
2958d6c refs/remotes/origin/master@{5}: update by push
6e9558c refs/remotes/origin/master@{6}: pull --rebase: fast-forward
8854b35 refs/remotes/origin/master@{7}: pull --rebase: fast-forward
b96f25d refs/remotes/origin/master@{8}: pull --rebase: fast-forward
efb0ab8 refs/remotes/origin/master@{9}: pull --rebase: fast-forward
71c12ca refs/remotes/origin/master@{10}: pull --rebase: fast-forward
d860e59 refs/remotes/origin/master@{11}: update by push
6342dbb refs/remotes/origin/master@{12}: fetch: fast-forward
...

你可以在这里看到,我最近的推送将origin/master6e9558c推进到2958d6c。要查看提交记录,可以使用git log 6e9558c..2958d6c。例如:

$ git log --abbrev-commit --pretty=oneline 6e9558c..2958d6c
2958d6c Commit Summary 4
5cbe548 Commit Summary 3
13d007c Commit Summary 2
4f19ac3 Commit Summary 1

如果您可以访问远程代码库的终端,您可以在那端执行类似的操作,以查看它收到的所有推送。

问题回答

Git不跟踪哪些提交是哪些“推送”操作的一部分;仓库要么包含特定的提交序列,要么不包含。Git不在乎提交如何到达,无论三个提交是否是一个推送的一部分,还是每个提交都是单独推送的。





相关问题
git confusion - cloning a repo is returning a past version

Im having some confusion with my git usage. I cloned a repo from one comp to the other, and the new clone is the state of the original that was active some time ago. So its cloning a past version. ...

Appropriate strategy for tagging and hotfixing with git

I was wondering if the strategy I m using for tagging and hotfixing tags (which then I use for deploying rails applications) with git is appropriate. For tagging I just tag a commit of the master ...

Tips on upgrading CVS to git/hg?

We still use CVS, I use git and hg for my personal use though I m still a novice at both, but I realize they re much more modern and better, faster, distributed, etc. It s just everyone is so ...

Using Git in a TFS shop

Using Git at home has spoiled me - I now find using TFS at work to be a bit of a drag and want to explore the possibility of using Git locally and syncing somehow with TFS. I figure there are a few ...

热门标签