美文网首页
Git常用命令

Git常用命令

作者: 请叫我女程序员 | 来源:发表于2018-04-25 15:24 被阅读0次

一.创建并切换到新分支

     eg:创建并切换到branch_test分支:

                    git checkout -b branch_test

二.删除本地分支

     eg:目前有分支branch_main和branch_test,要删除分支branch_test

            a.切换到branch_main分支(即切换到要删除分支之外的其它分支)

                    git checkout branch_main

            b.删除branch_test分支

                    git branch -d branch_test

三.删除远程分支

     eg:删除远程仓库的branch_test分支

                    git push origin --delete branch_test

四.打tag

    1. eg:给branch_test分支打tag,tag名称为V1.1.1

            a.切换到branch_test

                     git checkout branch_test 

            b.打tag

                     git tag V1.1.1

            c.推送所有的tag到远程

                     git push --tags

    2.查看所有tag

                     git tag -l

    3.删除tag

             eg:删除名称为V1.1.0的tag

                     git tag -d V1.1.0

五.合并分支

     eg:将branch_test合并到branch_main分支上

            a.切换到branch_main分支上

                     git checkout branch_main

            b.合并分支

                     git merge branch_test

六.重命名本地和远程分支

       eg:将本地和远程的branch_test重命名为branch_main

             a.重命名本地分支

                       git branch -m branch_test branch_main

              b.删除远程分支

                       git push origin --delete branch_test

              c.将本地分支推送到远程

                       git push origin branch_main

相关文章

网友评论

      本文标题:Git常用命令

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