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
相关推荐
Mr_Dwj5 小时前
【工具】Git 子仓库管理
git
Rysxt_12 小时前
Git Rebase 变基教程:作用、使用场景与合并的区别
git·变基
刘某某.14 小时前
提交 git 的三种方式
git
bigHead-16 小时前
Git 修改远程仓库地址的几种方法
git
杀手不太冷!17 小时前
Jenkins的安装与使用;git clone url的时候,url为http和ssh时候的区别
git·http·jenkins
qq_2290580118 小时前
GIT使用方法
git
YMGogre18 小时前
Git 多人协作开发
git
凯子坚持 c1 天前
Git 多人协作深度解析:从工作流模拟到仓库维护
git
要站在顶端1 天前
克隆大型仓库卡住(7%每次就卡住了)
git
五月底_1 天前
上传大量文件到github repo
git·github