git branch分支管理

1、管理内容:

查看、新建、删除、重命名

git帮助:

Administrator@FAN MINGW64 /e/debug/C (main)
$ git branch -h
usage: git branch [<options>] [-r | -a] [--merged] [--no-merged]
用法:git branch 设置 -r -a --合并 --不合并
   or: git branch [<options>] [-f] [--recurse-submodules] <branch-name> [<start-point>]
   or: git branch [<options>] [-l] [<pattern>...]
   or: git branch [<options>] [-r] (-d | -D) <branch-name>...
   or: git branch [<options>] (-m | -M) [<old-branch>] <new-branch>
   or: git branch [<options>] (-c | -C) [<old-branch>] <new-branch>
   or: git branch [<options>] [-r | -a] [--points-at]
   or: git branch [<options>] [-r | -a] [--format]

Generic options:一般设置
    -v, --verbose         show hash and subject, give twice for upstream branch
    -q, --quiet           suppress informational messages
    -t, --track[=(direct|inherit)]
                          set branch tracking configuration
    -u, --set-upstream-to <upstream>
                          change the upstream info
    --unset-upstream      unset the upstream info
    --color[=<when>]      use colored output
    -r, --remotes         act on remote-tracking branches
    --contains <commit>   print only branches that contain the commit
    --no-contains <commit>
                          print only branches that don't contain the commit
    --abbrev[=<n>]        use <n> digits to display object names

Specific git-branch actions:特定的git-branch操作
    -a, --all             list both remote-tracking and local branches
    -d, --delete          delete fully merged branch
    -D                    delete branch (even if not merged)
    -m, --move            move/rename a branch and its reflog
    -M                    move/rename a branch, even if target exists
    --omit-empty          do not output a newline after empty formatted refs
    -c, --copy            copy a branch and its reflog
    -C                    copy a branch, even if target exists
    -l, --list            list branch names
    --show-current        show current branch name
    --create-reflog       create the branch's reflog
    --edit-description    edit the description for the branch
    -f, --force           force creation, move/rename, deletion
    --merged <commit>     print only branches that are merged
    --no-merged <commit>  print only branches that are not merged
    --column[=<style>]    list branches in columns
    --sort <key>          field name to sort on
    --points-at <object>  print only branches of the object
    -i, --ignore-case     sorting and filtering are case insensitive
    --recurse-submodules  recurse through submodules
    --format <format>     format to use for the output

2、查看git branch [-r | -a]:

git branch查看本地所有分支

Administrator@FAN MINGW64 /e/debug/C语言 (main)
$ git branch
* main

git branch -r查看远程所有分支

Administrator@FAN MINGW64 /e/debug/C语言 (main)
$ git branch -r
  origin/main
  origin/master

git branch -a查看本地和远程所有分支

Administrator@FAN MINGW64 /e/debug/C语言 (main)
$ git branch -a
* main
  remotes/origin/main
  remotes/origin/master

 注意:一般当前本地分支前带有“*”号且为绿色(当前 HEAD 指针所指向的分支),远程分支为红色

3、新建分支 git branch [-f] <branchname>:

        git 中默认分支的名字是master(新版本git安装时默认是main分支),而origin是Git给克隆的仓库服务器的默认名字

git log命令查看当前各个分支当前所指的对象,git中有一个名为HEAD的特殊指针,它会指向当前所在的分支

$ git log
commit e263dac27dc89936fe691d309f79e67a6662faa7 (HEAD -> main, origin/main)
Author: knifeCF <1216522107@qq.com>
Date:   Wed Aug 2 16:03:00 2023 +0800

新建分支:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值