,在学习中你提交项目到GitHub中时,需要继续开发第二代版本,但是第一代版本又出现了bug,所以就用到了分支用法,
你创建仓库并且将项目提交到仓库中
$ git init
$ git add .
$ git commit -m"版本号"
使用 git branch查看当前的所有分支,默认就一个master主分支,前面*号代表你此时就在这个分支中,
使用 git branch 分支名 ,创建分支
然后在查看分支
利用 git checkout 分支名 ,来进入分支,并且查看*号所在位置
你在主分支上提交的代码不会影响其余分支,反之亦然,
当你感觉用不到分支时可以用以下 代码删除分支,查看 ,1.0分支已经删除
我们还可以进行主分支代码合并,marge命令,在master上将1.0分支合并,然而也不是随便合并的,有时候会出现代码冲突状况,这时候就需要你自己去代码中找到代码重复的地方,然后进行删除就可以了