从远程存储库获取所需提交的 sha1

发布于 2024-10-13 11:24:49 字数 73 浏览 1 评论 0原文

使用 git reflog ,用户只能访问他本地的 reflog 信息?

如何从远程存储库查看所需提交的 sha1?

Using git reflog, a user can only access his local reflog information?

How can one see the sha1 of a desired commit from a remote repository?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

遮了一弯 2024-10-20 11:24:49

Git reflog 是您签出的 sha1 的历史记录。对于您所在的任何存储库都是如此。如果删除您的存储库并再次克隆它,您将丢失该历史记录。

第二个问题没有意义。我猜您想要 git fetch ,然后浏览遥控器上尚未合并的内容。您可以使用 git log master..origin/master 来查看远程主机有哪些您没有的内容。

Git reflog is a history of sha1s you had checked out. This is true for whatever repository you're in. If delete your repository and clone it again, you will have lost that history.

The second question doesn't make sense. I'm guessing that you want to git fetch and then browse what is on the remote that you didn't merge yet. You would do that with git log master..origin/master to see what the remote master has that you don't.

鸠魁 2024-10-20 11:24:49

如果您想要特定分支的 SHA1,您可以尝试

git ls-remote <URL> <branch name>

,或者,如果分支名称模式不明确并且您想要更多控制,可能类似于:

git ls-remote <URL> | grep refs/heads/<branch name>

或类似的内容。它也适用于标签,但看起来没什么其他作用。

If you want the SHA1 of a particular branch, you could try

git ls-remote <URL> <branch name>

or, if the branch name pattern is ambiguous and you want more control, maybe something like:

git ls-remote <URL> | grep refs/heads/<branch name>

or something like that. It also works for tags, but it looks like not much else.

爱殇璃 2024-10-20 11:24:49

我知道这是一个老问题,但我需要 从特定提交分支< /a> 并且需要知道该提交的 SHA 才能执行此操作。在找到如何从 GUI(SourceTree)执行此操作后,我还找到了如何从命令行执行此操作。以下是步骤。

使用命令

  1. 行 转到您的存储库
  2. 目录 键入 git log
  3. 显示的每个提交的 SHA 位于 commit: 字段中。

使用源树
1. 找到您要查找的提交
2.右键单击它
3. 选择“将 SHA 复制到剪贴板”

I know this is an old question, but I needed to branch from a particular commit and needed to know the SHA of that commit in order to do so. After finding out how to do it from a GUI(SourceTree) I also found out how to do it from the command line. Here are the steps.

Using the command line

  1. Go to your repo directory
  2. Type git log
  3. The SHA for each commit displayed is in the commit: field.

Using SourceTree
1. Find the commit that you're looking for
2. Right click on it
3. Select "Copy SHA to Clipboard"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文