显示远程服务器上提交范围的 git 日志?
我正在寻找一种方法来查询 git 服务器的给定提交范围的日志。作为一名 SVN 用户,我的心态是错误的,所以我希望 GIT 专家能够提供帮助。我正在寻找类似的东西:
svn log -r 5:20 --xml svn.myserver.com
但是对于 git 服务器。换句话说,显示第 5 次提交到第 20 次提交的日志。感谢您的帮助。
I am looking for a way to query a git server for its logs for a given range of commits. Being an SVN user, I'm in the wrong mindset so Im hoping GIT experts can help. I'm looking to something similar to:
svn log -r 5:20 --xml svn.myserver.com
but for a git server. In other words, show me the logs for the 5th commit through to the 20th commit. thanks for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,由于 Git 没有简单的修订版号,因此您需要指定修订版,如 rev-parse 命令。
但直接查询远程存储库(无需克隆或获取数据)的唯一命令是 < code>git ls-remote,并且:
由于日志可以显示 diffstats 和完整差异,因此您不能在不至少在本地存储库中获取远程的情况下请求日志。
First, since there is no simple revision number with Git, you would specify revision as mentioned in the rev-parse command.
But the only command which queries directly a remote repo (without cloning or fetching data) is
git ls-remote
, and:Since log can show diffstats and full diffs, you cannot ask for logs without at least fetching a remote in a local repo.
我认为你试图从 Subversion 转移一些对 git 无效的假设。 Git 是一个分散的版本控制系统,因此所有的命令都针对存储库的本地克隆运行,而不是针对远程服务器。另外,在 git 中,没有单一的线性提交历史记录,因此您需要指定 SHA-1 提交 ID;您不能简单地使用修订号。
要获取日志,您必须首先将提交传输到存储库的本地克隆,然后才能查询它们。
如果您尚未克隆远程存储库,则需要运行
git clone REMOTE_URL
。或者,如果您想使用辅助远程服务器,可以在现有存储库中运行git remote add ALIAS OTHER_REMOTE_URL
。然后,您需要使用
git fetch origin
(如果您添加了辅助远程服务器,则使用git fetch ALIAS
)来获取提交。完成此操作后,您可以使用 git log origin/master~5..origin/master 列出提交(在远程存储库中的分支上)(例如,显示最后五个提交) 。或者您可以运行 git log master..origin/master 来显示尚未在本地合并的新远程提交。 (还有许多其他方法可以指定提交范围;有关详细信息,请参阅文档 或提出另一个问题。)
I think you're trying to transfer some assumptions from Subversion that aren't valid for git. Git is a decentralized version control system, so all¹ commands run against your local clone of the repository, not against a remote server. Also, in git, there isn't one single linear history of commits, so you need to specify SHA-1 commit IDs; you can't simply use revision numbers.
To get a log, you must first transfer the commits to your local clone of the repository, and then you can query them.
If you haven't already cloned the remote repository, you will need to run
git clone REMOTE_URL
. Alternatively, if you're wanting to use a secondary remote server, you can rungit remote add ALIAS OTHER_REMOTE_URL
in an existing repository.You'll then need to fetch the commits with
git fetch origin
(orgit fetch ALIAS
if you've added a secondary remote server).Once you've done that, you can list commits (on branches in the remote repository) with
git log origin/master~5..origin/master
(to show the last five commits, for example). Or you could rungit log master..origin/master
to show the new remote commits that haven't been merged locally yet. (There are many other ways to specify commit ranges; for more information see the documentation or open another question.)git ls-remote
do run against a remote server, but the majority do not.