美文网首页程序员
Git 快速使用 之 Git 分支 branch

Git 快速使用 之 Git 分支 branch

作者: mm_cuckoo | 来源:发表于2017-08-15 10:05 被阅读47次

查看分支

git 命令: $ git branch -a

说明:查看所有分支

cfox@cfox-PC:~/Disk/gitTest/NDKLearn
$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/dev
  remotes/origin/dev_1
  remotes/origin/dev_org
  remotes/origin/master

* 代表当前处在的分支,

切换分支

git 命令: $ git checkout dev

说明:切换到dev 分支上

cfox@cfox-PC:~/Disk/gitTest/NDKLearn
$ git checkout dev
M   app/src/main/res/values/colors.xml
Switched to branch 'dev'
Your branch is up-to-date with 'origin/dev'.
cfox@cfox-PC:~/Disk/gitTest/NDKLearn
$ git branch -a
* dev
  master
  remotes/origin/HEAD -> origin/master
  remotes/origin/dev
  remotes/origin/dev_1
  remotes/origin/dev_org
  remotes/origin/master
cfox@cfox-PC:~/Disk/gitTest/NDKLearn$ 

说明:M app/src/main/res/values/colors.xml 这条信息是告诉我们这个文件被我们修改了,但没有提交,会在该分支中体现

创建分支

git 命令: $ git branch new_branch

说明:创建新的名为 new_branch 分支

cfox@cfox-PC:~/Disk/gitTest/NDKLearn
$ git branch new_branch
cfox@cfox-PC:~/Disk/gitTest/NDKLearn
$ git branch -a
* dev
  master
  new_branch
  remotes/origin/HEAD -> origin/master
  remotes/origin/dev
  remotes/origin/dev_1
  remotes/origin/dev_org
  remotes/origin/master

删除分支

git 命令: $ git branch -d new_branch

说明:删除名为 new_branch 的分支

cfox@cfox-PC:~/Disk/gitTest/NDKLearn
$ git branch -d new_branch 
Deleted branch new_branch (was e4f191e).
cfox@cfox-PC:~/Disk/gitTest/NDKLearn
$ git branch -a
* dev
  master
  remotes/origin/HEAD -> origin/master
  remotes/origin/dev
  remotes/origin/dev_1
  remotes/origin/dev_org
  remotes/origin/master

将分支推到远程

git 命令 :$ git push origin new_branch

说明:将分支 new_branch 推送到远程

cfox@cfox-PC:~/Disk/gitTest/NDKLearn
$ git branch new_branch
cfox@cfox-PC:~/Disk/gitTest/NDKLearn
$ git branch -a
* dev
  master
  new_branch
  remotes/origin/HEAD -> origin/master
  remotes/origin/dev
  remotes/origin/dev_1
  remotes/origin/dev_org
  remotes/origin/master
cfox@cfox-PC:~/Disk/gitTest/NDKLearn
$ git push origin new_branch 
Total 0 (delta 0), reused 0 (delta 0)
To github.com:CNCFOX/NDKLearn.git
 * [new branch]      new_barnch -> new_branch
cfox@cfox-PC:~/Disk/gitTest/NDKLearn
$ git branch -a
* dev
  master
  new_branch
  remotes/origin/HEAD -> origin/master
  remotes/origin/dev
  remotes/origin/dev_1
  remotes/origin/dev_org
  remotes/origin/master
  remotes/origin/new_branch

删除远程分支

git 命令: $ git branch -r -d origin/new_barnch

说明: 删除远程跟踪分支 origin/new_barnch

git 命令: $ git push origin :new_barnch

说明: 将删除动作同步到远程

cfox@cfox-PC:~/Disk/gitTest/NDKLearn
$ git branch -a
* dev
  master
  new_barnch
  remotes/origin/HEAD -> origin/master
  remotes/origin/dev
  remotes/origin/dev_1
  remotes/origin/dev_org
  remotes/origin/master
  remotes/origin/new_barnch
cfox@cfox-PC:~/Disk/gitTest/NDKLearn
$ git branch -d new_barnch 
Deleted branch new_branch (was e4f191e).
cfox@cfox-PC:~/Disk/gitTest/NDKLearn
$ git branch -a
* dev
  master
  remotes/origin/HEAD -> origin/master
  remotes/origin/dev
  remotes/origin/dev_1
  remotes/origin/dev_org
  remotes/origin/master
  remotes/origin/new_barnch
cfox@cfox-PC:~/Disk/gitTest/NDKLearn
$ git branch -r -d origin/new_barnch 
Deleted remote-tracking branch origin/new_branch (was adb7752).
cfox@cfox-PC:~/Disk/gitTest/NDKLearn
$ git branch -a
* dev
  master
  remotes/origin/HEAD -> origin/master
  remotes/origin/dev
  remotes/origin/dev_1
  remotes/origin/dev_org
  remotes/origin/master
cfox@cfox-PC:~/Disk/gitTest/NDKLearn
$ git push origin :new_barnch 
To github.com:CNCFOX/NDKLearn.git
 - [deleted]         new_barnch

相关文章

  • 关于Git使用笔记

    Git使用分支: 查看所有分支:git branch -a 创建分支:git branch de 切换分支:git...

  • 创建与合并分支

    Git鼓励大量使用分支:查看分支:git branch创建分支:git branch 切换分支:git...

  • git分支和squelize-cli相关命令

    Git鼓励大量使用分支: 查看分支:git branch 创建分支:git branch 切换分支:git che...

  • Git 分支管理

    Git鼓励大量使用分支: 创建与合并分支 :查看分支:git branch创建分支:git branch

  • (4.1) git中分支管理-创建合并

    小结 Git鼓励大量使用分支:查看分支:git branch创建分支:git branch eg:g...

  • Branch

    Branch 的使用 $ git branch #查看本地分支$ git branch -r #查...

  • git的简单使用

    git的使用 1.查看远程分支 :git branch -a 2.查看本地分支:git branch 3.切换分支...

  • Git分支详解

    Git分支详解 git branch命令 查看分支 git branch 新建分支 git branch br...

  • Git命令学习

    分支 git branch : 查看分支git branch : 创建分支git branch -d...

  • git branch分支

    创建分支 git branch test 查看分支 git branch git branch -a 推送分支 g...

网友评论

    本文标题:Git 快速使用 之 Git 分支 branch

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