显示远程服务器上提交范围的 git 日志?

发布于 2024-11-06 08:03:39 字数 210 浏览 0 评论 0原文

我正在寻找一种方法来查询 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

舞袖。长 2024-11-13 08:03:39

首先,由于 Git 没有简单的修订版号,因此您需要指定修订版,如 rev-parse 命令

但直接查询远程存储库(无需克隆或获取数据)的唯一命令是 < code>git ls-remote,并且:

  • 它将仅显示 SHA1,而不显示日志消息。
  • 它适用于参考模式(头、标签、分支...),而不适用于转速。

由于日志可以显示 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:

  • it will display only SHA1, not the log message.
  • it works on ref patterns (head, tags, branches, ...), not with revs.

Since log can show diffstats and full diffs, you cannot ask for logs without at least fetching a remote in a local repo.

榕城若虚 2024-11-13 08:03:39

我认为你试图从 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 来显示尚未在本地合并的新远程提交。 (还有许多其他方法可以指定提交范围;有关详细信息,请参阅文档 或提出另一个问题。)


  1. 某些命令,例如 git ls-remote 确实针对远程服务器运行,但大多数命令不会。

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 run git remote add ALIAS OTHER_REMOTE_URL in an existing repository.

You'll then need to fetch the commits with git fetch origin (or git 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 run git 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.)


  1. Some commands, such as git ls-remote do run against a remote server, but the majority do not.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文