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
相关推荐
唐青枫5 小时前
为什么 .gitignore 不生效?其实你忘了用 git rm --cached!
git
代码or搬砖1 天前
Git学习笔记(三)
笔记·git·学习
虾说羊1 天前
git连接远程仓库并拉去推送以及克隆命令
git
IT~狂男1 天前
GIT 实战命令操作大全,代码变动,推动,修改备注,撤销(篇幅一)
git
前端拿破轮1 天前
从0到1搭一个monorepo项目(一)
前端·javascript·git
消失的旧时光-19431 天前
git的 Rebase
git
风禾万里2 天前
Git怎么管理软件版本(代码,模型,配置等)
git
默默coding的程序猿2 天前
3.git的分支携带问题是什么?怎么解决?
java·git·python·svn·gitee·github·intellij-idea
天地人-神君2 天前
将.idea取消git托管
java·git·intellij-idea
Zach_yuan2 天前
版本控制器Git
linux·git