git: how to see changes due to push?

2019-03-18 05:04发布

I can't quite figure out how to see what exactly was changed, in the remote repository, by a 'push'. 'git log' shows me the series of commits but those took place in my local repository and were pushed at different times; I would like to know which commits were part of each specific 'push'

2条回答
混吃等死
2楼-- · 2019-03-18 05:08

Git doesn't keep track of which commits were part of which "push" operation; either the repository contains a certain sequence of commits, or it doesn't. It doesn't matter to Git how the commits got there, whether a group of three commits was part of one push, or each one was done in a separate push.

查看更多
对你真心纯属浪费
3楼-- · 2019-03-18 05:13

Actually, you can fish this information out of the reflog. It's not the full history of the remote repository but rather it's the history of your copy of the remote repository's branch. So, you will not see changes that were made to the remote repository by other people. It's not pretty, but you can probably write a script to make it easier.

For example:

$ 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
...

You can see here that my most recent push advanced origin/master from 6e9558c to 2958d6c. To see the commits you can use git log 6e9558c..2958d6c. E.g.,

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

If you have terminal access to the remote repository, you could do something similar on that end to see all of the pushes that it received.

查看更多
登录 后发表回答