【Git】Git 分支管理 ( 解决分支合并冲突 | 创建并切换分支 git switch -c feature1 | 修改 feature1 分支并提交 | 修改 master 主版本并提交 )
生活随笔
收集整理的這篇文章主要介紹了
【Git】Git 分支管理 ( 解决分支合并冲突 | 创建并切换分支 git switch -c feature1 | 修改 feature1 分支并提交 | 修改 master 主版本并提交 )
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
文章目錄
- 一、創(chuàng)建并切換分支 git switch -c feature1
- 二、修改 feature1 分支并提交
- 三、修改 master 主版本并提交
一、創(chuàng)建并切換分支 git switch -c feature1
執(zhí)行
git switch -c feature1命令 , 創(chuàng)建分支 feature1 , 并切換到該分支 ;
執(zhí)行過程 :
D:\Git\git-learning-course>git switch -c feature1 Switched to a new branch 'feature1'D:\Git\git-learning-course>二、修改 feature1 分支并提交
修改 feature1 中的 README.txt 文件內(nèi)容為 feature1 , 并執(zhí)行 git add README.txt 和 git commit -m "feature1" 命令提交到版本庫(kù) ;
執(zhí)行過程 :
D:\Git\git-learning-course>git switch -c feature1 Switched to a new branch 'feature1'D:\Git\git-learning-course>git add README.txtD:\Git\git-learning-course>git commit -m "feature1" [feature1 26b1978] feature11 file changed, 1 insertion(+), 1 deletion(-)三、修改 master 主版本并提交
修改 master 中的 README.txt 文件內(nèi)容為 master , 并執(zhí)行 git add README.txt 和 git commit -m "feature1" 命令提交到版本庫(kù) ;
執(zhí)行過程 :
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.txtD:\Git\git-learning-course>git commit -m "master" [master c9842ef] master1 file changed, 1 insertion(+), 1 deletion(-)D:\Git\git-learning-course>git branchfeature1 * master上述操作的目的是 , 在 master 分支中修改 README.txt 文件 , 在 feature1 分支中修改 README.txt 文件 , 兩個(gè)分支中的相同文件內(nèi)容不同 , 必然會(huì)導(dǎo)致沖突產(chǎn)生 ;
總結(jié)
以上是生活随笔為你收集整理的【Git】Git 分支管理 ( 解决分支合并冲突 | 创建并切换分支 git switch -c feature1 | 修改 feature1 分支并提交 | 修改 master 主版本并提交 )的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【错误记录】Git 使用报错 ( git
- 下一篇: 【Git】Git 分支管理 ( 解决分支