git branch -r vs git remote显示来源 [英] git branch -r vs git remote show origin
问题描述
所以我一直在寻找一种方法来查看遥控器上存在的所有分支的列表,并找到以下2个命令:
So I was looking for a way to see a list of all the branches that exist on the remote, and found the following 2 commands:
1. git branch -r
2. git remote show origin
1. git branch -r
2. git remote show origin
这两个命令有什么区别?
Whats the difference between the 2 commands?
推荐答案
git branch
命令查看(或以不同方式调用,修改)您自己的存储库信息.对于远程跟踪分支(git branch -r
),这将显示您上次git与这些远程服务器联系并获取更新时在远程服务器上缓存的副本中的内容.
The git branch
command looks at (or, invoked differently, modifies) your own repository's information. For remote-tracking branches (git branch -r
), this shows what's in your cached copy of what was on the remotes the last time you had your git contact those remotes and get updates.
默认情况下,git remote show name
命令运行git ls-remote
,该命令实际上通过Internet电话(或您使用的任何其他传输方式)调用远程服务器,并立即从中获取信息. >.如果您运行git fetch
,这将放入缓存的副本中. (请注意,如果您之后 do 运行git fetch
,那么到那时您得到的结果可能会完全不同,因为即使是几毫秒的时间也可能会花费大量时间来进行大规模更改.这完全取决于如何处于活动状态.)
The git remote show name
command, by default, runs git ls-remote
, which actually calls up the remote's server over the Internet-phone (or whatever other transport you use) and gets information from it right now. This is what would be put into your cached copy, if you ran git fetch
. (Note that if you do run git fetch
afterward, what you get by then could be totally different, since even a few milliseconds can be plenty of time to have massive changes occur. It all depends on how active the remote is.)
您可以告诉git remote show
仅使用缓存的副本,而不用拨打Internet电话上的遥控器.在这种情况下,这两个命令使用相同的基本信息(但呈现方式却大不相同-git remote show
旨在帮助您显示fetch
和push
会做什么,而git branch -r
只是列出缓存中的内容)
You can tell git remote show
to use only your cached copy, rather than calling up the remote on the Internet-phone. In this case, the two commands use the same basic information (but present it very differently—git remote show
is intended to help you show what fetch
and push
would do, while git branch -r
simply lists what's in your cache).
这篇关于git branch -r vs git remote显示来源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!