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 小时前
shell编程之awk命令详解
linux·服务器·git
baiyu334 小时前
成为git砖家(12): 看懂git合并分支时冲突提示符
git
wu_aceo8 小时前
将本地项目提交到Gitee
git·gitee·提交·本地提交·上传git
随便取个六字18 小时前
GIT操作 学习
git·学习
星源~1 天前
tree 命令集成到 Git Bash:可视化目录结构的指南
git·单片机·物联网·嵌入式·项目开发
zhaqonianzhu1 天前
git gerrit安装钩子
git·gerrit
这是个栗子1 天前
【问题解决】VSCode终端中看不到Git-Bash
ide·git·vscode
悲伤小伞1 天前
linux_git的使用
linux·c语言·c++·git
天机️灵韵1 天前
云效DevOps vs Gitee vs 自建GitLab的技术选型
git·开源项目
荔枝吻2 天前
【AI总结】Git vs GitHub vs GitLab:深度解析三者联系与核心区别
人工智能·git·github