美文网首页
Github创建新分支

Github创建新分支

作者: 一只肥豚鼠 | 来源:发表于2019-02-15 19:22 被阅读0次

    一、clone Repository

    clone Github 上的Repository,如下:

    git clone https://github.com/siskinc/siskinc.github.io
    

    二、管理分支

    1、查看分支

    1、查看本地分支

    使用 git branch命令,如下:

    $ git branch
    * master
    

    *标识的是你当前所在的分支。

    2、查看远程分支

    命令如下:

    git branch -r
    

    3、查看所有分支

    命令如下:

    git branch -a
    

    2、本地创建新的分支

    命令如下:

    git branch [branch name]
    

    例如:

    git branch save
    

    3、切换到新的分支

    命令如下:

    git checkout [branch name]
    

    例如:

    $ git checkout save
    

    4、创建+切换分支

    创建分支的同时切换到该分支上,命令如下:

    git checkout -b [branch name]
    

    git checkout -b [branch name] 的效果相当于以下两步操作:

    git branch [branch name]
    git checkout [branch name]
    

    5、将新分支推送到github

    命令如下:

    git push origin [branch name]
    

    例如:

    git push origin save
    

    6、删除本地分支

    命令如下:

    git branch -d [branch name]
    

    例如:

    git branch -d save
    

    7、删除github远程分支

    命令如下:

    git push origin :[branch name]
    

    分支名前的冒号代表删除。
    例如:

    git push origin :save

    相关文章

      网友评论

          本文标题:Github创建新分支

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