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
相关推荐
前端若水19 小时前
git回退并合并分支操作
git
程序员鱼皮1 天前
Git WorkTree 是什么?凭什么能让 AI 编程效率翻倍?
git·ai·程序员·编程·ai编程
懵逼的小黑子1 天前
git与远程仓库创建连接
git
前端若水1 天前
Git 撤销与恢复完全指南(超级详细版)
大数据·git·elasticsearch
golang学习记1 天前
Git 2.54 来了,这个新命令让我终于敢重写历史了
git·后端
其实防守也摸鱼1 天前
AWVS下载和安装保姆级教程
linux·服务器·git
前端若水1 天前
Git 可以做的所有操作(完整分类)
大数据·git·elasticsearch
叹一曲当时只道是寻常1 天前
Reference 工具安装与使用教程:一条命令管理 Git 仓库引用与知识沉淀
人工智能·git·ai·开源·github
前端若水1 天前
Git 仓库管理命令完全指南(超级详细版)
大数据·git·elasticsearch
小MarkK1 天前
[Doc]git的使用之不上传服务器,只在本地管理
git