美文网首页
git创建与合并分支

git创建与合并分支

作者: 该死的金箍 | 来源:发表于2020-07-06 09:21 被阅读0次

    1.创建并切换分支 test
    可以使用 git checkout -b  test  或者使用 git swith -c test

    2.查看分支 
    git branch

    带*号的代表当前所在分支


    3.在test分支上正常提交

    touch test.txt          创建test.txt文件 并在文件中写入add test.txt
    git add test 
    git commit -m "add test"

    4.切换分支
    git checkout master   切换到master分支
    git switch master   效果和上面的一样
    由下图可以看出:在test分支下,可以查看到添加了test.txt文件
    当切换到master分支下,没有test.txt文件

    5.合并分支
    通过 git merge test 合并test分支
    这里使用的是Fast-forward 模式  :快速合并模式

    6.删除分支
    git branch -d test

    git log --graph  --pretty=oneline  --abbrev-commit
    其中, --graph 是图形化, --pretty=oneline 是一行显示, --abbrev-commit 是只显示每次提交id的前几位

    还有第二种合并方式
    git merge --no-ff -m "merge with no-ff" test  这样合并后还能看到对应的分支信息

    相关文章

      网友评论

          本文标题:git创建与合并分支

          本文链接:https://www.haomeiwen.com/subject/wteuqktx.html