submodule切换分支_git子模块分支会随主项目的分支切换吗?
Recently I got to know git submodules. They appear to be self-sufficient projects with their own git structure and branches.
When I switch main project's branch, does this also switch submodule's branch? How does git handle this situation?
解决方案
I recently came across a similar question. (I'll let you read the content of this answer as it gives you the background to my answer).
A submodule is just a reference to a repo and a commit in this repo.
When you switch branch, the reference may change (if the branch you're switching to uses a different reference) but the filesystem of the submobule will remain untouched.
So writing git status will yield a result showing that your submodule status differs from the one in your current HEAD.
To make the submodule point to the right commit for HEAD, simply invoke:
$ git submodule update
In addition, the branch of your submodule is not interesting to the enclosing repo as the reference is always added toward a commit and not toward a branch. The branches in your submodule will therefore only reflect your branching strategy for the submodule and do not need to match the enclosing repository's branching strategy.
submodule切换分支_git子模块分支会随主项目的分支切换吗?相关推荐
- git 新建分支并切换到该分支_Git 从master拉取代码创建新分支 并且再将修改合并到master...
开发过程中经常用到从master分支copy一个开发分支: 1.切换到master分支 git checkout master 2.获取最新的代码 git pull origin master 3 ...
- git 切换分支_git 入门教程之分支总览
分支就是一条独立的时间线,既有分支,必有主干,正如一棵树谈到树枝,必有树干一样的道理.我们先前对git 的全部操作默认都是在主干上进行的,这个主干也是一种特殊的分支,名为 master 分支. 无论是 ...
- 拉取远程分支_git clone切换分支步骤,代理设置,作者信息设置
1.克隆远程仓库 git clone git地址 2.查看所有分支 git branch –a 3.切换分支 git checkout branchName 4.查看当前所在分支 git branch ...
- git 新建分支并切换到该分支_git分支的创建、删除、切换、合并
1. 先看一下git的命令: 查看本地分支 git branch : 查看远程分支 git branch -r : 切换分支 git checkout -b agrochemical origin/a ...
- git本地ben远程分支_git 本地分支与远程分支
1. 克隆代码 git clone https://github.com/master-dev.git # 这个git路径是无效的,示例而已 2. 查看所有分支 git branch --all # ...
- git本地ben远程分支_Git本地分支和远程分支关联
1.创建分支 git branch develop 2.查看本地分支: git branch 注:名称前面加* 号的是当前的分支 3.查看远程分支: 加上-a参数可以查看远程分支,远程分支会用红色表示 ...
- git 怎么备份本地分支_Git常用个人备份笔记
一.新建代码库 1.在当前目录下创建一个Git代码库 git init 创建的.git默认是隐藏的,使用命令ls -ah显示出来. 2.新建一个目录,并初始化为Git的代码库 git init [di ...
- git 小乌龟 更新分支_git常用操作
Git 是一个开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目. Git 是 Linus Torvalds 为了帮助管理 Linux 内核开发而开发的一个开放源码的版本控制软件. Git ...
- git master主分支_Git分支管理策略及简单操作
前几天整理了一下之前项目的开发代码,当时使用了Git来进行代码版本管理.虽然本人熟悉常用的Git操作,但是对分支的管理经验非常欠缺.拿这个项目来说,在项目中有不下20个分支,每个分支间的继承关系相当之 ...
最新文章
- HashMap、HashTable、ConcurrentHashMap、HashSet区别 线程安全类
- 两边放动物对战守城的游戏_集合啦!动物森友会定制周边;百战天虫 大混战发布...
- 柱状图添加数字标签_Python之利用Plotnine作图(一)——简单柱状图
- 1、C++招聘笔试--C++中的C
- Nginx源码阅读(ngx_http_process_request_line)
- 《C专家编程》第二章——这不是Bug,而是语言特性
- ES6/07/Array的扩展方法,...扩展运算符,Array.from(),(arr.find(),arr.findIndex()和arr.includes())模板字符串,Set数据结构
- 英特尔回应苹果换芯:将继续支持老客户,但我的CPU才是最好的
- JavaSE_1 基本概念
- 12.用户和组账户管理
- 服务器安装配置lldp协议
- java计算机毕业设计足球队管理系统源码+数据库+系统+lw文档+mybatis+运行部署
- 独立站运营到底要做什么!
- 零基础计算机入门,分享人人可以参考的路线,私藏的干货视频和书单,为你的程序员生涯助力,呐喊!
- chrome 91版本 解决跨域请求SameSite
- 纯CSS实现下雪、下雨、落叶效果
- C++ primer plus 第六章课后习题
- java生成指定位数的随机英文字符串
- 【TCP的拥塞控制】基于窗口的拥塞控制
- direct do造句 sb to_wish sb to do造句