Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Git的所有远程分支的头提交_Git_Commit_Remote Branch - Fatal编程技术网

使用Git的所有远程分支的头提交

使用Git的所有远程分支的头提交,git,commit,remote-branch,Git,Commit,Remote Branch,我知道如何列出远程分支 $ git branch -a 我知道如何找到我当前分支的头提交散列 $ git rev-parse HEAD 但我不知道如何列出所有远程分支的所有头提交哈希。这接近我想要的,但它们的顺序是什么 $ git rev-parse --remotes 4b9f7128e9e7fa7d72652ba49c90c37d0727123d 4ebab9616fac6896b7827e8502b4dc7c5aac6b5b ea7a5fab4a757fb0826253acf1fe7d

我知道如何列出远程分支

$ git branch -a
我知道如何找到我当前分支的头提交散列

$ git rev-parse HEAD
但我不知道如何列出所有远程分支的所有头提交哈希。这接近我想要的,但它们的顺序是什么

$ git rev-parse --remotes
4b9f7128e9e7fa7d72652ba49c90c37d0727123d
4ebab9616fac6896b7827e8502b4dc7c5aac6b5b
ea7a5fab4a757fb0826253acf1fe7d8c546c178e
...
理想情况下,我想要一个分支名称提交散列对列表,甚至是一种将远程分支名称传递给git rev parse HEAD的方法,请使用

git branch -r -v --no-abbrev
并忽略提交消息或

git show-ref

并从refs/remotes开始过滤结果。

您可以使用
git rev parse
进行此操作。它可以接受任何看起来甚至很像提交的内容,并返回该提交的完整SHA1哈希

例如,要获取头的SHA1,请执行以下操作:

git rev-parse HEAD
要获取
主机的SHA1

git rev-parse master
要获取源站/中继站的SHA1,请执行以下操作:

git rev-parse origin/trunk
要获取所有远程磁头的SHA1(这只是众多方法之一,当然不是最好的方法):


我知道这是老生常谈,但我认为
gitlsremote
也适用于此

git ls-remote --heads origin

fcce961b46784fae13be8a30c2622ddd34d970ec        refs/heads/develop
9da7bb692a72235451706f24790a3f7a100a64e2        refs/heads/feature-netty-testing
86020c50d86691caecff4a55d3b1f2f588f6291d        refs/heads/javafx-testing
871d715e5c072b1fbfacecc986f678214fa0b585        refs/heads/master
7ed641c96d910542edeced5fc470d63b8b4734f0        refs/heads/orphan-branch

有些关联
git show ref
也为标记提供哈希值。要知道这些是标记本身的散列,而不是它们指向的提交。
git ls-remote --heads origin

fcce961b46784fae13be8a30c2622ddd34d970ec        refs/heads/develop
9da7bb692a72235451706f24790a3f7a100a64e2        refs/heads/feature-netty-testing
86020c50d86691caecff4a55d3b1f2f588f6291d        refs/heads/javafx-testing
871d715e5c072b1fbfacecc986f678214fa0b585        refs/heads/master
7ed641c96d910542edeced5fc470d63b8b4734f0        refs/heads/orphan-branch