Git本地分支关联远程分支

Git本地分支关联远程分支

本地分支相关操作

  • 查看本地分支

    shell 复制代码
    git branch
  • 新建本地分支

    shell 复制代码
    git branch name
  • 切换本地分支

    shell 复制代码
    git checkout name
  • 新建本地分支并切换到该分支

    shell 复制代码
    git checkout -b name 
    #或
    git branch name
  • 删除本地分支

    shell 复制代码
    git branch -d name
    git branch -D name #强制删除

远程分支相关操作

  • 查看远程和本地所有分支

    shell 复制代码
    git branch -a
  • 新建远程分支

    shell 复制代码
    git checkout -b localname #首先在本地新建分支
    git push origin localname:remotename #将本地分支同步到远程,完成新建远程分支
  • 本地分支连接远程分支

    shell 复制代码
    git branch --set-upstream-to=origin/remotename
    #或
    git branch -u origin/remotename
  • 根据远程分支新建本地分支

    shell 复制代码
    git checkout -b name origin/remotename
    #或
    git branch --set-upstream-to=origin/remotename localname
  • 删除远程分支(慎重

    shell 复制代码
    git push origin :remotename
    #或
    git push origin --delete remotename
相关推荐
小喻yushi2 分钟前
Git入门
git
大柏怎么被偷了23 分钟前
【Git】基本操作
linux·运维·git
摇滚侠3 小时前
零基础小白自学 Git_Github 教程,Git 命令行操作2,笔记19
笔记·git·github
我是若尘3 小时前
Git Rebase深度解析:优雅重写提交历史的艺术
git
我是若尘4 小时前
Git合并踩坑记:当master回退后,如何正确合并分支?
git·代码规范
摇滚侠4 小时前
零基础小白自学 Git_Github 教程,Action CI/CD 完整实践,笔记23
笔记·git·ci/cd
minji...6 小时前
linux 进程控制(一) (fork进程创建,exit进程终止)
linux·运维·服务器·c++·git·算法
系夏普6 小时前
Git 入门教程:初始化、修改与提交
git
laplaya6 小时前
Git 使用技巧
git
奶油松果7 小时前
git amend记录
git