当前位置: 首页 > news >正文

git branch -r(--remotes )显示你本地仓库知道的所有 远程分支 的列表

好的,git branch -r 这个命令用于列出远程分支。让我详细解释一下:

命令:

git branch -r
dgq@dgqdeMac-mini ProductAuthentication % git branch -rorigin/main

作用:

这个命令会显示你本地仓库知道的所有 远程分支 的列表。它不会显示你的本地分支,只显示远程仓库的分支。

输出格式:

输出通常会类似于这样:

  origin/HEAD -> origin/mainorigin/developorigin/mainorigin/feature/new-featureorigin/bugfix/fix-issue
  • origin/HEAD -> origin/main: 这表示远程仓库 origin 的 HEAD 指针指向 origin/main 分支。HEAD 指针通常表示远程仓库的默认分支(通常是 mainmaster)。
  • origin/develop, origin/main: 这些是远程仓库 origin 上的实际分支。origin/ 前缀表示它们是 origin 远程仓库的分支。

关键概念:

  • 远程仓库 (remote): 远程仓库是托管你的代码的版本库,通常托管在诸如 GitHub、GitLab、Bitbucket 等平台上。origin 是通常用来表示默认远程仓库的名称。
  • 远程分支 (remote branch): 远程分支是远程仓库中的分支的本地镜像。 它们以 远程仓库名称/分支名称 的形式显示,例如 origin/main。 远程分支是为了让你跟踪远程仓库的状态,方便你从远程仓库拉取更新或向远程仓库推送你的更改。
  • git branch -a vs git branch -r:
    • git branch -a 会列出所有的分支,包括本地分支和远程分支。
    • git branch -r 只列出远程分支。

使用场景:

  • 查看远程分支列表: 当你需要知道远程仓库上有哪些分支时,可以用这个命令。
  • 检查远程分支的 HEAD 指针: 查看远程仓库的默认分支。
  • 拉取远程分支: 在执行 git checkout -b <本地分支名> <远程分支名> 命令时, 你需要知道远程分支的名称。
  • 同步本地仓库和远程仓库:git fetch 后,你可以使用 git branch -r 来查看远程分支的最新状态。

总结:

git branch -r 是一个很有用的命令,可以让你查看和了解远程仓库的分支状态。它主要用于查看远程仓库中的分支信息,而不是你的本地分支。 它会让你明白远程仓库有哪些可用的分支,从而让你更好的组织你的本地开发工作。


git branch -r 中的 -r 的英文全称是 --remotes

所以,git branch -r 实际上是 git branch --remotes 的简写。

dgq@dgqdeMac-mini ProductAuthentication % git branch -help
usage: git branch [<options>] [-r | -a] [--merged] [--no-merged]or: git branch [<options>] [-f] [--recurse-submodules] <branch-name> [<start-point>]or: git branch [<options>] [-l] [<pattern>...]or: git branch [<options>] [-r] (-d | -D) <branch-name>...or: git branch [<options>] (-m | -M) [<old-branch>] <new-branch>or: git branch [<options>] (-c | -C) [<old-branch>] <new-branch>or: git branch [<options>] [-r | -a] [--points-at]or: git branch [<options>] [-r | -a] [--format]Generic options-v, --verbose         show hash and subject, give twice for upstream branch-q, --quiet           suppress informational messages-t, --track[=(direct|inherit)]set branch tracking configuration-u, --set-upstream-to <upstream>change the upstream info--unset-upstream      unset the upstream info--color[=<when>]      use colored output-r, --remotes         act on remote-tracking branches--contains <commit>   print only branches that contain the commit--no-contains <commit>print only branches that don't contain the commit--abbrev[=<n>]        use <n> digits to display object namesSpecific git-branch actions:-a, --all             list both remote-tracking and local branches-d, --delete          delete fully merged branch-D                    delete branch (even if not merged)-m, --move            move/rename a branch and its reflog-M                    move/rename a branch, even if target exists-c, --copy            copy a branch and its reflog-C                    copy a branch, even if target exists-l, --list            list branch names--show-current        show current branch name--create-reflog       create the branch's reflog--edit-description    edit the description for the branch-f, --force           force creation, move/rename, deletion--merged <commit>     print only branches that are merged--no-merged <commit>  print only branches that are not merged--column[=<style>]    list branches in columns--sort <key>          field name to sort on--points-at <object>  print only branches of the object-i, --ignore-case     sorting and filtering are case insensitive--recurse-submodules  recurse through submodules--format <format>     format to use for the output

在这里插入图片描述

http://www.lryc.cn/news/506061.html

相关文章:

  • Typescript安装
  • 使用C#在目录层次结构中搜索文件以查找目标字符串
  • 基于Redis实现令牌桶算法
  • [Java] 使用 VSCode 来开发 Java
  • 奇怪的知识又增加了,ESP32下的Lisp编程:ULisp--Lisp for microcontrollers
  • STM32标准库学习之寄存器方法点亮LED灯
  • Jenkins:持续集成与持续部署的利器
  • 概率论得学习和整理30: 用EXCEL 描述泊松分布 poisson distribution
  • 汽车SoC芯片及其安全岛设计与未来发展趋势(学习笔记)
  • 【排序算法】——选择排序
  • 第十五章 Linux Shell 编程
  • 【c++笔试强训】(第三十八篇)
  • go 自己写序列化函数不转义
  • 一般行业安全管理人员考试题库分享
  • Marketo REST API 批量修改邮件内容
  • 《云原生安全攻防》-- K8s安全框架:认证、鉴权与准入控制
  • 淘宝获取sku详细信息 API
  • 基于Spring Boot的体育商品推荐系统
  • C++小细节笔记
  • go语言并发读写数据队列,不停写的同时,一次最多读取指定量数据(逐行注释)
  • 密码学——密码学概述、分类、加密技术(山东省大数据职称考试)
  • 【数据库MySQL篇二】MySQL数据库入门基础教程:一网打尽数据库和表各种操作、命令和语法
  • Android 解决“Could not resolve all artifacts for configuration ‘:classpath‘方法
  • 青少年编程与数学 02-004 Go语言Web编程 08课题、使用Gin框架
  • PostgreSQL: 事务年龄
  • C# 识别二维码
  • KeepAlive与RouterView缓存
  • RK3588 , mpp硬编码rgb, 保存MP4视频文件.
  • 使用 Wireshark 和 Lua 脚本解析通讯报文
  • ElasticSearch08-分析器详解