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
相关推荐
LannyChung7 小时前
PowerShell 下 git log 中文乱码的完整排查与解决
windows·git
import_random8 小时前
[git]本地main,origin/main,远程main(关系2)
git
golang学习记8 小时前
Zed Git重大更新:目录级对比支持分栏Diff
git·vscode·zed
阿俊-全栈开发13 小时前
LikeShop 单商户高级版二开项目的 Git 分支管理与版本发布规范
git·likeshop·likeshop开源商城·likeshop多商户
努力弹琴的大风天13 小时前
TortoiseGit 仓库不显示绿色对号解决方案
git·tortoisegit·图标显示
我不会插花弄玉16 小时前
GitHub实操【由浅入深-Git】
git·github
说实话起个名字真难啊17 小时前
Git常用小问题笔记
笔记·git·elasticsearch
橙露1 天前
git简明教程以及资源分享
大数据·git
codigger2 天前
别再靠"最终版-改"活下去了:一篇讲透 Git 与 GitHub
git·程序员·github·编程·控制版本
JustNow_Man2 天前
【Harness】本地文本向量化搜索解决方案--qmd
git·python·算法