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
新建分支: