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
相关推荐
凉、介6 小时前
Git 深入理解(二) | 常用命令
大数据·git·elasticsearch
xuxie991 天前
GIT版本管理
git
茶栀(*´I`*)1 天前
Git从零开始操作清单
git
李永奉1 天前
Git和GitHub-Git 管理的版本数据到底保存在哪个文件夹里?
git·github
Mortalbreeze1 天前
Git 基础篇(二):本地仓库管理与常用操作
git
武昌库里写JAVA4 天前
SpringBoot+Vue 项目介绍
java·javascript·git·sql·ai
Hvitur6 天前
Git - 多分支合并
git·github
考虑考虑6 天前
git刷新远程分支列表
git·后端·gitlab
AI大模型-小华6 天前
Codex 自动测试怎么用?从生成测试用例到修复失败用例
git·测试用例·ai编程·软件开发·codex·chatgpt pro·codex cli
七分辣度7 天前
GitHub/Git 常用命令及使用场景
git·github