git:如何查看因推送而导致的更改?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2282952/
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: how to see changes due to push?
提问by c-urchin
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'
我不太清楚如何通过“推送”查看远程存储库中究竟发生了什么变化。“git log”向我展示了一系列提交,但这些提交发生在我的本地存储库中并在不同时间推送;我想知道哪些提交是每个特定“推送”的一部分
回答by Pat Notz
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.
实际上,您可以从 reflog 中获取这些信息。它不是远程存储库的完整历史记录,而是远程存储库分支副本的历史记录。因此,您不会看到其他人对远程存储库所做的更改。这不是很漂亮,但您可能可以编写一个脚本以使其更容易。
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.,
你可以在这里看到我最近的推送origin/master
从6e9558c
到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
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.
如果您具有远程存储库的终端访问权限,则可以在该端执行类似操作以查看它收到的所有推送。
回答by Greg Hewgill
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.
Git 不会跟踪哪些提交属于哪些“推送”操作;存储库要么包含特定的提交序列,要么不包含。对于 Git 而言,提交是如何到达那里的,三个提交的组是一次推送的一部分,还是每个提交都在单独的推送中完成,都无关紧要。