美文网首页Android知识Android技术知识Git使用
Git -- 提交本地分支到远端分支/拉取远程分支

Git -- 提交本地分支到远端分支/拉取远程分支

作者: GYLEE | 来源:发表于2017-03-31 23:13 被阅读933次
    • 创建新分支

    git branch newbranch

    git checkout -b newbranch 创建并切换到新分支

    • 展示分支

    git branch

    • 切换分支

    git checkout newbranch

    • 推送本地新建分支到远端分支(远端会自动创建分支)

    git push origin newbranch:originbranch

    • 删除远端分支

    git push origin :originbranch

    • 拉取远程分支到本地

    git fetch origin 远程分支名x:本地分支名x
    (个人使用经历:此语句会自动创建分支,但是必须指定本地分支名,否则则拉取分支失败 git branch --set-upstream-to=origin/XXX XXX 建立分支之间的跟踪关系 )

    • 修改分支名并推到远端

    git branch -m old_branch new_branch # Rename branch locally
    git push origin :old_branch # Delete the old branch
    git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote

    相关文章

      网友评论

        本文标题:Git -- 提交本地分支到远端分支/拉取远程分支

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