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
相关推荐
int WINGsssss2 小时前
Git使用
git
用户0760530354384 小时前
Git Revert:安全移除错误提交的方式
git
Good_Starry16 小时前
Git介绍--github/gitee/gitlab使用
git·gitee·gitlab·github
云端奇趣21 小时前
探索 3 个有趣的 GitHub 学习资源库
经验分享·git·学习·github
F_D_Z1 天前
【解决办法】git clone报错unable to access ‘xxx‘: SSL certificate problem:
网络·git·网络协议·ssl
等风来不如迎风去1 天前
【git】main|REBASE 2/6
git
艾伦~耶格尔1 天前
IDEA 配置 Git 详解
java·ide·git·后端·intellij-idea
云兮杜康1 天前
IDEA中用过git之后文件名颜色全变红
java·git·intellij-idea
睡不醒的小泽1 天前
git merge 和 git rebase
git
艾伦~耶格尔1 天前
Git 下载及安装超详教程(2024)
git·gitee·码仓