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
相关推荐
测试开发技术8 小时前
使用 Git 时出现 unable to access,如何解决?
git·面试题
zhougl9969 小时前
git项目,有idea文件夹,怎么去掉
java·git·intellij-idea
tmacfrank17 小时前
Git 使用技巧与原理(一)—— 基础操作
git
dilvx17 小时前
git 配置 default editor
git
特种加菲猫21 小时前
构建完整工具链:GCC/G++ + Makefile + Git 自动化开发流程
linux·笔记·git·自动化
Franklin1 天前
VS 版本更新git安全保护问题的解决
git
我是一只代码狗1 天前
idea中合并git分支
git
我是一只代码狗1 天前
idea中使用git
git·gitee·github
恋喵大鲤鱼2 天前
git restore
git·git restore
李少兄2 天前
Git Commit Message写错后如何修改?已Push的提交如何安全修复?
git·安全