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
相关推荐
小鸡脚来咯4 小时前
Git 新手入门指南
大数据·git·elasticsearch
一允8 小时前
Git学习记录
git·学习
程序员果子10 小时前
GraphRAG:让大模型在知识图谱中精准导航
人工智能·git·语言模型·aigc·知识图谱
later_rql13 小时前
【Git提交remote rejected】
git
Tatalaluola15 小时前
Git版本控制常用命令
git
我有酒两杯16 小时前
记录一次git使用
git
caz2816 小时前
git bash突然ssh不能用了
git·ssh·bash
Remember_99317 小时前
【JavaSE】一站式掌握Java面向对象编程:从类与对象到继承、多态、抽象与接口
java·开发语言·数据结构·ide·git·leetcode·eclipse
移远通信17 小时前
短信的应用
java·git·python
论迹17 小时前
【Git】-- 分支管理
git·ubuntu·版本控制