执行
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 中的 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(-)
修改 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
上述操作的目的是 , 在 master 分支中修改 README.txt 文件 , 在 feature1 分支中修改 README.txt 文件 , 两个分支中的相同文件内容不同 , 必然会导致冲突产生 ;