【Git】Git 分支管理 ( 解决分支合并冲突 | 创建并切换分支 git switch -c feature1 | 修改 feature1 分支并提交 | 修改 master 主版本并提交 )

简介: 【Git】Git 分支管理 ( 解决分支合并冲突 | 创建并切换分支 git switch -c feature1 | 修改 feature1 分支并提交 | 修改 master 主版本并提交 )

文章目录

一、创建并切换分支 git switch -c feature1

二、修改 feature1 分支并提交

三、修改 master 主版本并提交





一、创建并切换分支 git switch -c feature1


执行


git switch -c feature1


命令 , 创建分支 feature1 , 并切换到该分支 ;



执行过程 :


D:\Git\git-learning-course>git switch -c feature1
Switched to a new branch 'feature1'
D:\Git\git-learning-course>

image.png






二、修改 feature1 分支并提交


修改 feature1 中的 README.txt 文件内容为 feature1 , 并执行 git add README.txt 和 git commit -m "feature1" 命令提交到版本库 ;



执行过程 :


D:\Git\git-learning-course>git switch -c feature1
Switched to a new branch 'feature1'
D:\Git\git-learning-course>git add README.txt
D:\Git\git-learning-course>git commit -m "feature1"
[feature1 26b1978] feature1
 1 file changed, 1 insertion(+), 1 deletion(-)

image.png





三、修改 master 主版本并提交


修改 master 中的 README.txt 文件内容为 master , 并执行 git add README.txt 和 git commit -m "feature1" 命令提交到版本库 ;



执行过程 :


D:\Git\git-learning-course>git switch master
Switched to branch 'master'
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)
D:\Git\git-learning-course>git add README.txt
D:\Git\git-learning-course>git commit -m "master"
[master c9842ef] master
 1 file changed, 1 insertion(+), 1 deletion(-)
D:\Git\git-learning-course>git branch
  feature1
* master


image.png


上述操作的目的是 , 在 master 分支中修改 README.txt 文件 , 在 feature1 分支中修改 README.txt 文件 , 两个分支中的相同文件内容不同 , 必然会导致冲突产生 ;


目录
相关文章
|
3月前
|
开发工具 git
git分支管理master/hotfix/develop/feature/release
采用合理的Git分支管理模型可以显著提升团队协作效率和代码管理的质量。本文介绍的 `master`、`develop`、`feature`、`release`和 `hotfix`分支模型是一个行之有效的方法,适用于大多数软件开发项目。通过清晰地划分各个分支的职责,团队成员可以更专注于各自的开发任务,同时确保代码库的稳定性和可维护性。
143 2
|
8月前
|
开发工具 数据中心 git
详解IDEA git 版本回滚
详解IDEA git 版本回滚
319 0
|
9月前
|
存储 开发工具 数据库
git的标签管理
git的标签管理
|
5月前
|
安全 开发工具 git
git合并错了,我想回退到之前的版本
git合并错了,我想回退到之前的版本
|
4月前
|
编译器 网络安全 开发工具
git学习五:切换本地仓库出现的问题。修改git配置初始化。error:src refspec master does not match any。错误总结,送上几个案例
这篇文章是关于Git使用中遇到的一些问题及其解决方案的总结,包括切换本地仓库时的问题、修改Git初始化配置、以及解决"error: src refspec master does not match any"错误等。
136 0
|
5月前
|
开发工具 git
7-5git reset --hard origin/master代表什么意思
7-5git reset --hard origin/master代表什么意思
|
6月前
|
Shell 开发工具 git
|
7月前
|
开发工具 git
unable to index file ‘~$git提交版本号.xlsx‘
unable to index file ‘~$git提交版本号.xlsx‘
|
7月前
|
存储 开发工具 git
好的git管理方法,标明项目_编号_(功能,不过还是在没有bug出现时就提交为好)+Excel表管理的格式
好的git管理方法,标明项目_编号_(功能,不过还是在没有bug出现时就提交为好)+Excel表管理的格式
|
8月前
|
开发工具 git
技巧分享:Git怎么修改已经提交版本的版本注释
技巧分享:Git怎么修改已经提交版本的版本注释
115 4