美文网首页
git分支管理

git分支管理

作者: EldonZhao | 来源:发表于2017-09-04 11:00 被阅读47次

一、创建新分支:

  • 新建分支:
macbook:portal zhaoxueyong$ git checkout -b branch-test
M   project/settings.py
Switched to a new branch 'branch-test'
macbook:portal zhaoxueyong$ git status 
On branch branch-test
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   project/settings.py

no changes added to commit (use "git add" and/or "git commit -a")
macbook:portal zhaoxueyong$ git push origin branch-test 
Total 0 (delta 0), reused 0 (delta 0)
To http://code.cbpmgt.com/VPC/portal.git
 * [new branch]        branch-test -> branch-test
macbook:portal zhaoxueyong$ git branch -a
* branch-test
  master
  release-2.0
  remotes/origin/HEAD -> origin/master
  remotes/origin/branch-test
  remotes/origin/master
  remotes/origin/release-1.0
  remotes/origin/release-2.0
  • 查看gitlab上分支情况:


    分支情况

二、页面上删除分支:

点击上图分支后的删除按钮删除对应分支;

三、本地查看分支:

macbook:portal zhaoxueyong$ git branch -a
* branch-test
  master
  release-2.0
  remotes/origin/HEAD -> origin/master
  remotes/origin/branch-test
  remotes/origin/master
  remotes/origin/release-1.0
  remotes/origin/release-2.0

四、本地同步分支:

macbook:portal zhaoxueyong$ git fetch origin 
macbook:portal zhaoxueyong$ git branch -a
* branch-test
  master
  release-2.0
  remotes/origin/HEAD -> origin/master
  remotes/origin/branch-test
  remotes/origin/master
  remotes/origin/release-1.0
  remotes/origin/release-2.0

由上述操作知,git fetch不能在本地同步删除远端已经删除的分支;

macbook:portal zhaoxueyong$ git remote prune origin
Pruning origin
URL: http://jrzhaoxueyong:xyz198920@code.cbpmgt.com/VPC/portal.git
 * [pruned] origin/branch-test
macbook:portal zhaoxueyong$ git branch -a
* branch-test
  master
  release-2.0
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/origin/release-1.0
  remotes/origin/release-2.0

可以看到remotes中已经没有branch-test的分支了;
此时把本地的branch-test分支删除即可;

macbook:portal zhaoxueyong$ git checkout master 
M   project/settings.py
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
macbook:portal zhaoxueyong$ git branch -d branch-test 
Deleted branch branch-test (was 5bfd8184).
macbook:portal zhaoxueyong$ git branch
* master
  release-2.0

相关文章

  • git常用命令

    分支管理 git 切换分支 git 查看远程分支 git 查看本地分支 git 创建本地分支 git 删除本地分支...

  • Git命令整理

    Git命令 ———————————————— git配置: git基本步骤: git分支管理: 创建分支命令: 切...

  • GIT分支管理

    GIT 分支管理 参考:在阿里,我们如何管理代码分支?GitHub Flow & Git Flow 基于Git...

  • git常用操作

    Basic Operation 分支管理切换分支git checkout git checkout -b #...

  • git提交代码规范管理

    GIT分支管理 git远程分支主要包括:master develop fixbugmaster:整个项目主分支,...

  • 2021-11-30

    一、分支管理 1、创建分支 git branch 2、查看分支 git branch...

  • git分支仓库管理

    git分支和标签管理 创建分支 git branch banchName git checkout -b bra...

  • git分支管理与使用规范

    git分支管理与使用规范 分支管理 flow git flow github flow gitlab flow f...

  • git 创建分支提交远程分支

    Git创建与管理远程分支 1.创建本地分支 git branch 分支名,例如:git branch 2.0.1....

  • 2016-06-24 阅读整理

    Git Git 基础命令Git 分支管理Git 分支合并Git 公钥提交Git 常用技巧Git 设置别名 Andr...

网友评论

      本文标题:git分支管理

      本文链接:https://www.haomeiwen.com/subject/ikfrrxtx.html