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
相关推荐
木子杳衫2 小时前
【Git】处理报错原因
git
SHIPKING3932 小时前
【Git】2025全图文详解安装教程
git
无限进步_3 小时前
C语言atoi函数实现详解:从基础到优化
c语言·开发语言·c++·git·后端·github·visual studio
地球没有花18 小时前
gitlab cicd首次操作
运维·git·ci/cd·gitlab
无限进步_1 天前
【C语言】贪吃蛇游戏设计思路深度解析:从零开始理解每个模块
c语言·开发语言·c++·git·游戏·github·visual studio
达子6661 天前
git使用应用实战大全
git
P***25392 天前
Git教程
git
Slow菜鸟2 天前
Java 开发环境安装指南(五) | Git 安装
java·git
计算衎2 天前
Git 命令 作用、常用选项、示例、何时使用与注意事项指南
git·源代码管理
小生不才yz2 天前
(三)分支与合并 - git cherry-pick 命令的使用
git