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
相关推荐
大卫小东(Sheldon)8 小时前
GIM 2.0 发布:真正让 AI 提交消息可定制、可控、可项目级优化
git·rust·gim
知识即是力量ol11 小时前
研发实战:Git 规范化开发全流程指南
git·gitee·github
我是一只代码狗11 小时前
idea创建分支
git
知识即是力量ol13 小时前
Git 快速入门 (实习生视角)
git·gitee·github
Dontla14 小时前
Git撤销上一次提交(撤销提交,Git回退提交)git reset、git revert
git
wdfk_prog14 小时前
解决 `git cherry-pick` 引入大量新文件的问题
大数据·git·elasticsearch
fu的博客16 小时前
Git从删库到跑路
git·gitee·github
要加油哦~16 小时前
git 报错 | husky - pre-commit hook exited with code 1 解决
git
知识即是力量ol17 小时前
Git 实战指南:从分支管理到冲突解决
git·github·源代码管理
weixin_462446231 天前
Git 本地忽略 application-dev.yml 的最佳实践:不提交 .gitignore,不影响团队协作!
git