【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>二、修改 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.txtD:\Git\git-learning-course>git commit -m "feature1" [feature1 26b1978] feature11 file changed, 1 insertion(+), 1 deletion(-)三、修改 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.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 文件 , 兩個分支中的相同文件內容不同 , 必然會導致沖突產生 ;
總結
以上是生活随笔為你收集整理的【Git】Git 分支管理 ( 解决分支合并冲突 | 创建并切换分支 git switch -c feature1 | 修改 feature1 分支并提交 | 修改 master 主版本并提交 )的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【错误记录】Git 使用报错 ( git
- 下一篇: 【Git】Git 分支管理 ( 解决分支